-
Notifications
You must be signed in to change notification settings - Fork 395
Home
Tom Harrington edited this page Apr 20, 2019
·
5 revisions
Generates Objective-C and Swift code for your Core Data custom classes.
Use mogenerator
to generate custom subclasses of NSManagedObject
for entities in your model file. Generated code has two classes per entity. One is the "machine" file which is automatically regenerated as needed. The other "human" file is generated only when it doesn't already exist.
For example, for an entity named Event
, the classes are:
-
_Event
: Subclass ofNSManagedObject
. This file will be regenerated bymogenerator
if theEvent
model has changed. Normally you would not edit this file. -
Event
: Subclass of_Event
. This file is generated only if it does not exist, and is never regenerated. This is where you put custom code.
Xcode has included the ability to generate Core Data subclasses for many years, and recent versions of Xcode do so automatically. mogenerator
strives to generate better, more powerful code.
Some benefits include:
- Enumerations of attribtue and relationship names, which eliminates the need for "stringly tpyed" code.
- Swift property types. Why use a plain
NSSet
when you can have a typedSet
? - Convenience code to look up a subclass entity name and description.
- Add custom
import
s to generated code, which is useful for transformable properties with custom types. - Create your own templates for your custom classes.
- Support for Swift enumerations with Foundation raw value types.
- Use a custom base class as the ancestor of your model classes.