好的,我最近遵循了一个实现NSFetchedResultController的教程 它的工作很棒!我还找到了一个关于如何删除行的答案的问题。我将建议的代码行添加到我的实现文件中。
向左滑动并按下删除按钮时没有任何反应。没有错误,没有删除行,也没有崩溃。
这是我的代码
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source
[self.managedObjectContext deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
NSError *error = nil;
if (![self.managedObjectContext save:&error]) {
// handle error
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
}
我可能做错了什么?
答案 0 :(得分:0)
我明白了,我有;
[self.managedObjectContext deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]];
它必须是
[context deleteObject:[self.fetchedResultsController objectAtIndexPath:indexPath]]; Thank you very much for your response!