Preparing the Fetched Results Controller

When the “master” view controller is set up using Xcode’s Master Detail template, Xcode creates a property for the fetched results controller, and overrides the accessor method (fetchedResultsController) to lazy load or initialize the fetched results controller the first time it is requested. First the method checks to see whether the fetched results controller has already been initialized:

if (__fetchedResultsController != nil){  return __fetchedResultsController;}

If the fetched results controller is already set up, it is returned. Otherwise, a new fetched results controller is set up, starting with a fetch request:

NSFetchRequest *fetchRequest ...

Get iOS Components and Frameworks: Understanding the Advanced Features of the iOS SDK 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.