O'Reilly logo

Cocoa Programming for OS X: The Big Nerd Ranch Guide by Aaron Hillegass, Adam Preble, Nate Chandler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required