NSFetchedResultsController crashes on -controllerDidChangeContent: on inserting new record and saving to persistentStore.
Code:
- (void)controller:(NSFetchedResultsController *)controller
didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath
forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
NSLog(@"== UPDATING indexPath (%@) newIndexPath (%@) type %i", indexPath, newIndexPath, (int)type);
switch (type) {
case NSFetchedResultsChangeDelete: {
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
break;
}
case NSFetchedResultsChangeInsert: {
[self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationBottom];
break;
}
case NSFetchedResultsChangeMove: {
[self.tableView moveRowAtIndexPath:indexPath toIndexPath:newIndexPath];
break;
}
case NSFetchedResultsChangeUpdate: {
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
break;
}
default:
break;
}
}
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller {
NSLog(@"== BEGIN UPDATING");
[self.tableView beginUpdates];
}
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller {
NSLog(@"== END UPDATING");
[self.tableView endUpdates];
}
Note:- In target application FetchedResults delegate was implemented in UITableViewController subclass. And FetchedResultsController was working with child managed object context.
Possible sources of error (please provide an error message):
NSMainQueueConcurrencyType.-controller:didChangeSection:atIndex:forChangeType:is not implemented.