Co-Founder of Hyperpublic. Fighting the good fight.
Just need a place to file mistakes and avoid repeating them
Another issue which stumped me for awhile in the learning process....
If you edit an entity, which will cause a UITableViewCell to move from one section to the other based on the sectionNameKeyPath, then you have to remove the cell from the old index path and insert it at the new index path. Failing to do so will cause the NSInternalInconsistency exception stating that the number of rows before the edit doesn't match the number of rows for a section after the edit. You can handle it using the NSFetchedResultsChangeMove case of the controllerWillChangeContent method in the NSFetchedResultsControllerDelegate protocol. Now to figure out how to handle the case where a section gets deleted or created.When using a UITableViewController, it seems that if you set the controller's editing property, then it the super call takes care of setting the tableView property's edit property as well. This fires off calls to delegate methods responding to edit mode for the UITableView and the UITableViewCell's.
However, if you are using a UIViewController with a custom UITableView property as the table view's delegate, then the setEditing super call does not pass on the editing property to the UITableView. Be sure to call it from the setEditing method yourself on the table view:- (void)setEditing:(BOOL)editing animated:(BOOL)animated { [super setEditing:editing animated:animated]; [self.myTableView setEditing:editing animated:animated]