Part 2: Implementing NSFetchedResultsControllerDelegate

The code in this chapter works so far, but there is one potential problem. Each time the data in the managed object context is updated by an addition, a deletion, or a change, you send performFetch: to the fetch results controller. The call can result in far more work and time than simply updating only the changed data.

The fetched results controller has the ability to observe changes in the managed object context and call methods when those changes occur. All you need to do is support the NSFetchedResultsControllerDelegate protocol. You start by declaring support for the protocol:

1. Open CarTableViewController.h and add the following line of code just below the import of UIKit:

#import ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.