core-datapersistent-object-storensmanagedobjectmodel

what are differences between Managed object model and Persistent object store?


From apple CoreData framework docs,

Managed object model: A model allows Core Data to map from records in a persistent store to managed objects that you use in your application. Refer here.

Persistent object store: A persistent object store maps between objects in your application and records in a persistent store. Refer here.

From these description, both are meaning the same that is mapping persistent store records with managed objects.

I would like to know what is the unique difference between Managed object model and Persistent object store.


Solution

  • The managed object model is an instance of NSManagedObjectModel and describes the schema used in your Core Data application. It is loaded from the model file which contains all the entity descriptions with their attributes and relationships that you defined in the Core Data Model inspector. So the model describes your objects.

    The persistent object store is an instance of NSPersistentStore, which manages the transactions to and from a persistent store, which is the repository where the actual data is stored. In many cases, the persistent store is a SQLite file, but it can also be an XML file, a binary file or a "in-memory" store for temporary data.

    The persistent store coordinator uses both: The NSManagedObjectModel and (one or more) NSPersistentStores, to load managed objects from the store into the application and to write changed objects back into the store.