In my understanding, NSFetchedResultsController do the job of sync data from managed object context to a table view controller. What’s the role of the delegate here? I read the apple documentation and don’t get it. Please elaborate the issue concisely and to the point.
In my understanding, NSFetchedResultsController do the job of sync data from managed object context
Share
Well, the brief answer is that the delegate methods allow you to update the table view as appropriate when an action has been taken on a managed object in the NSFetchedResultsController (NSFRC).
For example, if you delete an object that’s in the NSFRC’s results then it can update the table by removing the appropriate row.
So…
In
controllerWillChangeContent:it is a good idea to tell your table view that you’re going to change it (so you should callbeginUpdates:on it)controller:didChangeObject:atIndexPath:forChangeTypeis called when a managed object changes (added, removed, moved, etc). Update the table view as appropriate (e.g. by callingdeleteRowsAtIndexPaths:withRowAnimation:if a managed object was deleted)controller:didChangeSection:atIndex:forChangeTypeis similar to the above, but for table view sections.controllerDidChangeContentis called when the changes are complete. Finish up in this method also callendUpdates:on your table viewHope this helps somewhat.