Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 17. Core Data > Model, Context, and Store

Model, Context, and Store

The preceding task created the model used to create entities and their relationships in a managed object context. When an application runs, it needs a model instance, the context, and the persistent store. The persistent store and the model are largely transparent to you when coding your application. You simply obtain both these items and then set properties referencing them in the managed object context. Because we started from a navigation-based application template set to use Core Data, Xcode added code to create and manage these for us.

NSManagedObjectModel

As discussed earlier, an application’s managed object model contains entities and their relationships. It serves as an application’s schema by describing the entities used in an application’s managed object context. Take a look at DogBreedsAppDelegate and you will see that Xcode added a property to the AppDelegate to hold the NSManagedObjectModel and an accessor method that creates the managedObjectModel on the first access. The easiest way to obtain the model is through the mergedModelFromBundles: class method.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint