Managed Object Model
Managed Object Model
The collection of elements that make up a blueprint outlining the managed object we utilize in our application is known as the Managed Object Model. Put otherwise, the Managed object model can be thought of as a schema that is utilized by CoreData.
It is an NSManagedObjectModel class instance. On the other hand, the entities, attributes, and relationships of the application are included in the Managed Object Model. We established entities and gave them values in the tutorial’s previous section.
Core Data may map records from a persistent store to managed objects we utilize in the application using a managed object paradigm. Entity description objects (instances of NSEntityDescription) make up the model.
An entity’s properties, as well as the name of the class that the entity is represented by in the application, are all described in an entity description.
Creating an Entity
As previously covered in this tutorial, we must choose the Use CoreData checkbox in the XCode project in order to use CoreData.
Thus, a.xcdatamodeled class will be created. Click the Add Entity button in the xcdatamodeled class, as seen in the image below, to create an entity.
Defining an Entity
In the XCode’s entity window on the right, we can define the entity. It is important to note that the class name and the entity name in this case are different. The class hierarchy and the entity structure in the data model might not line up. The image below displays the entity pane.
Abstract Entities
If we don’t make any instances of an entity, it’s considered abstract. If we have several entities that all derive from a single entity that shouldn’t be instantiated, we call that entity abstract. For instance, we can designate Person as an abstract entity in the Student entity and stipulate that only concrete subentities (Students) may be constructed. We are telling Core Data that an object will never be explicitly created by designating it as abstract in the object tab of the Data Model inspector.