NSFetchedResultsChangeDelete not being triggered

南笙酒味 提交于 2019-12-06 02:12:18

Can you show the code that builds the NSFetchedResultsController? Now that you have the save in your code as @DVG suggested then you should be getting callbacks. Perhaps your delegate is not being set properly.

Update

As I suspected you are not setting the delegate on the NSFetchedResultsController:

[fetchedResultsController setDelegate:self];

You should start receiving updates after adding that line around where you call -performFetch:.

It looks like you need to implement editingStyleForRowAtIndexPath to actually declare the cells your trying to delete as deletable.

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
  return UITableViewCellEditingStyleDelete;
}

Also, it doesn't appear that your saving your managedObjectContext.

EDIT: So it sounds like your model is commiting, but your tableview is reloading.

Try implementing

- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
  [self.tableView beginUpdates];
}

- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
  [self.tableView endUpdates];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!