There are two projects we can make use of:
We can learn from them what is needed to make our CoreData implementation work with Apple's file formats.
CoreData Code Generation
Xcode generates code for Core Data entities through a build-time process that creates NSManagedObject subclasses or extensions based on the Codegen setting in the Data Model Inspector. The generated files are compiled into the project's DerivedData directory rather than appearing in the project navigator, ensuring they stay in sync with the model file.
The generation behavior depends on the specific Codegen option selected for each entity:
- Class Definition: Xcode automatically generates both the entity class and its properties extension during the build. This is the default for new entities and requires no manual file management, though the generated properties are typically optional regardless of model constraints.
- Category/Extension: Xcode generates only the properties extension (e.g.,
Entity+CoreDataProperties.h/m), while the developer must manually create the base class (e.g., Entity+CoreDataClass.h/m). This allows for custom class hierarchies and business logic.
- Manual/None: Xcode generates no code. The developer must manually create and maintain the
NSManagedObject subclass and its properties using Editor > Create NSManagedObject Subclass or by writing the code directly.
There are two projects we can make use of:
We can learn from them what is needed to make our CoreData implementation work with Apple's file formats.
CoreData Code Generation
Xcode generates code for Core Data entities through a build-time process that creates
NSManagedObjectsubclasses or extensions based on the Codegen setting in the Data Model Inspector. The generated files are compiled into the project'sDerivedDatadirectory rather than appearing in the project navigator, ensuring they stay in sync with the model file.The generation behavior depends on the specific Codegen option selected for each entity:
Entity+CoreDataProperties.h/m), while the developer must manually create the base class (e.g.,Entity+CoreDataClass.h/m). This allows for custom class hierarchies and business logic.NSManagedObjectsubclass and its properties usingEditor>Create NSManagedObject Subclassor by writing the code directly.