Iphone 收到意外的“;EXC#u坏访问”;
从表视图中删除单元格时:发生以下错误:Iphone 收到意外的“;EXC#u坏访问”;,iphone,xcode,exc-bad-access,Iphone,Xcode,Exc Bad Access,从表视图中删除单元格时:发生以下错误: Program received signal: “EXC_BAD_ACCESS”. warning: Unable to read symbols for /Xcode3.2.5/Platforms/iPhoneOS.platform/DeviceSupport/4.3.2 (8H7)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found). 在这里,我从单元格
Program received signal: “EXC_BAD_ACCESS”.
warning: Unable to read symbols for /Xcode3.2.5/Platforms/iPhoneOS.platform/DeviceSupport/4.3.2 (8H7)/Symbols/Developer/usr/lib/libXcodeDebuggerSupport.dylib (file not found).
在这里,我从单元格中删除对象,并从calander中删除其事件:
if (editingStyle == UITableViewCellEditingStyleDelete)
{
//Get the object to delete from the array.
lovkid *mykids = (lovkid *)[appDelegate.actionarray1 objectAtIndex:indexPath.row];
appDelegate.actionId = mykids.Id;
//delete from calender
if( [ mykids.Event isEqualToString:@"empty"])
{
}
else
{
EKEvent* event2 = [appDelegate.eventStore eventWithIdentifier:mykids.Event];
if (event2 != nil)
{
NSError* error = nil;
[appDelegate.eventStore removeEvent:event2 span:EKSpanThisEvent error:&error];
}
}
//delete end
[mykids deleteAction];
[appDelegate.actionarray1 removeObjectAtIndex:indexPath.row];
//Delete the object from the table.
[localTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[localTable reloadData];
a = 0;
}
else
{
//NSLog(@"test");
}
从数据库中删除:
deleteStmt1 = nil;
if(deleteStmt1 == nil)
{
const char *sql = "delete from actions where id = ?";
if(sqlite3_prepare_v2(database1, sql, -1, &deleteStmt1, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating delete statement. '%s'", sqlite3_errmsg(database1));
//When binding parameters, index starts from 1 and not zero.
sqlite3_bind_int(deleteStmt1, 1,(int)appDelegate.actionId);
if (SQLITE_DONE != sqlite3_step(deleteStmt1))
NSAssert1(0, @"Error while deleting. '%s'", sqlite3_errmsg(database1));
sqlite3_reset(deleteStmt1);
sqlite3_finalize(deleteStmt1);
}
出现此错误的原因是什么?我建议删除该行:
[localTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
如果要通过reloadData
重新加载表,则不必以这种方式删除行。将重新加载该表,以反映新的数据源状态
另一方面,如果您想要更平滑地刷新表,则可以研究beginUpdates
和endUpdates
。在这种情况下,使用deleteRowsAtIndexPaths
是有意义的
我不知道这是否能解决你的车祸。如果没有,我建议您在调试器下执行,这样您就可以准确地找出导致崩溃的错误语句。日志上怎么说?它撞在哪条线上?第一步是。完成此操作后,构建并运行应用程序,然后告诉我们更详细的错误消息。我还必须删除动画。令人沮丧的。