我支持删除包含tableView的UIView中的行:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
[self.fetchedResultsController.managedObjectContext
deleteObject:[self.fetchedResultsController
objectAtIndexPath:indexPath]];
NSError *error;
if (![[self.fetchedResultsController managedObjectContext] save:&error]) {
NSLog(@"Unresolved error %@, %@, %@", error, [error userInfo],
[error localizedDescription]);
}
else {NSLog(@"Apparently successful");}
[self.tableView reloadData];
}
}
当我尝试这样做时,我在控制台中得到“显然成功”的消息,但是在configureCell中得到一个SIGABRT。就好像某个地方的对象还没有被删除,而configureCell正试图呈现一个丢失的对象。(不过,当我重新运行应用程序时,记录就消失了。)
有什么想法吗?