I have been looking at the NSFetchedResultsControllerDelegate Protocol Reference and some sample code online and have noticed two different implementations for updating a UITableViewCell when calling:
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject
atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type
newIndexPath:(NSIndexPath *)newIndexPath {
Can anyone explain the two different approaches?
They are:
// ONE
case NSFetchedResultsChangeUpdate:
[self configureCell:[tableView cellForRowAtIndexPath:indexPath]atIndexPath:indexPath];
break;
OR
// TWO
case NSFetchedResultsChangeUpdate:
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
break;
As a selectors’ names imply, in case ONE a cell is configured in a custom method (not Apple’s API) and most probably will be updated when a reload of the table view occurs.
In a TWO case reloadRowsAtIndexPaths: is
UITableViewmethod where you have an animation effect “for free”. How and where a cell is updated? Can’t tell without a code.