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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.