Managed Object Model
Managed Object Model can be defined as the set of objects that are used to form a blueprint describing the managed object we use in our application. In other words, the Managed object model can be seen as a schema that the CoreData uses.
It is an instance of NSManagedObjectModel class. However, the Managed Object Model includes the application’s entities, the properties, and the relationship between them. In the previous section of this tutorial, we have created entities and added values to them.
A managed object model allows Core Data to map from records in a persistent store to managed objects that we use in the application. The model is a collection of entity description objects (instances of NSEntityDescription).
An entity description describes an entity, the name of the class used to represent the entity in the application., and it’s properties.
Creating an Entity
As we have discussed in the previous section of this tutorial, if we want to use CoreData in the XCode project, we need to check the Use CoreData checkbox.
This will create a .xcdatamodeled class. To create an entity, click Add Entity button in the xcdatamodeled class, as shown in the below image.
Defining an Entity
We can define the entity in the entity pane in the right of the XCode. Here, we must notice that the entity name and the class name are not the same. The entity structure in the data model may not match the class hierarchy. The entity pane is shown in the following image.
An entity is abstract if we do not create any instances of that entity. We make an entity abstract if we have a number of entities that all inherit from a common entity that should not itself be instantiated. For example, in the Student entity, we can define Person as an abstract entity and specify that only concrete subentities (Student) can be instantiated. By marking an entity as abstract in the Entity pane of the Data Model inspector, We are informing Core Data that it will never be instantiated directly.