Chapter 3
iOS: NSFetchedResultsController

The NSFetchedResultsController was introduced alongside Core Data when the framework was added to iOS with version 3.0. Since its introduction, developers have settled into a love--hate relationship with this class. When it’s used in the way it was intended, it works extremely well. The hate part comes in when developers attempt to use the NSFetchedResultsController outside of its intended niche—that’s when things start to fall apart quickly.

The NSFetchedResultsController is designed to be the glue between Core Data and the UITableView. When Core Data was first added to iOS, the Core Data team realized that there was a significant amount of work to get Core Data and table views talking well. They removed nearly all of that work with the introduction of the NSFetchedResultsController.

In this chapter, we discuss what the NSFetchedResultsController is designed to do and how it works. Once you have a handle on how it works, we’ll explore alternatives so you know what to use when NSFetchedResultsController is not the correct fit.