Fetching Objects from the NSManagedObjectContext

While this chapter’s exercise demonstrates the power of bindings combined with Core Data, it is not uncommon to use Core Data programmatically.

In order to fetch objects from the NSManagedObjectContext you will first need to create an NSFetchRequest. A fetch has a number of similarities to NSArrayController, except that it is typically only used once, while an array controller is continuously updated.

At a minimum you will need the name of the entity you want to fetch. Without anything more, the fetch request will return all of the objects for that entity name. You will usually want to filter and order the results, however. For that you will provide an NSPredicate and/or an ...

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide 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.