Part 1: Integrating NSFetchedResultsController

You need an instance variable to hold the fetched results controller. Add the following declaration below the one for fetchRequest after the @implementation statement at the top of CarTableViewController.m:

NSFetchedResultsController *fetchedResultsController;

Now you need to initialize the fetched results controller. Doing so requires setting up an appropriate fetch request. This is because NSFetchedResultsController maps the result of applying a fetch request to a managed object context into index paths.

In Listing 9-2, you used a simple NSFetchRequest for returning all CDCar entities. A fetched results controller requires at least a filter and a sort. The filter can ...

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

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