Home > Articles > Home & Office Computing > Mac OS X

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

NSManagedObject

Every entity stored in the context is represented by the NSManagedObject class. Instead of writing a separate class for each type of entity in the model, a single class is used to represent all of them. Due to the key-value protocols, this representation is completely transparent to the developer. When objects are retrieved from the context, all the relationships in that entity are populated as well. If any of the linked objects have relationships, they will also be populated. It is necessary to keep this in mind when designing the object model as it is quite easy to accidentally pull the entire context into memory if everything is linked tightly.

If functionality beyond simple data storage is required, it is possible to extend NSManagedObject and add the functionality to the subclass. To get the context to use the subclass, it needs to be specified in the model. Once specified, the subclass will be initialized and populated automatically when the data is requested.

  • + Share This
  • 🔖 Save To Your Account