Skip to content

Core Data User Info Keys

AliSoftware edited this page Aug 8, 2014 · 8 revisions

Mogenerator uses the Core Data model's User Info key-value pairs to apply special behavior to specific entities and attributes. You can find these key-value pairs in the Data Model Inspector when editing a Core Data model. An example:

Entity Key-Value Pairs

Key Description Values
mogenerator.customBaseClass By default, classes are generated as subclasses of NSManagedObject. Set this key to have your Core Data entity's superclass set to your specified class. The name of your class, such as MyCustomNSManagedObject
additionalHeaderFileName If you set this key, a #import directive will be added to the machine-generated file to import this file. This is especially useful when you use attributeValueScalarType to a custom enum value and you have to #import the file where the enum is defined. The exact name of the file to #import (including the .h extension)

Attribute Key-Value Pairs

Key Description Values
mogenerator.readonly Make this generated @property readonly YES, NO
attributeTransformableProtocols
attributeValueClassName By default, the class used for each object attribute is the class matching the one defined in the xcdatamodel. Set this key to force to use a custom class instead. The name of the custom class
attributeValueScalarType Set this key to force to use a custom type for scalars. This is especially useful when you use a typedef'd enum and want your attribute to use this enum instead of being typed uint16_t or uint8_t (or whatever the type used internally in your CoreData model). Note: You may also need to specify the key for additionalHeaderFileName in your Entity's UserInfo so that the file where the enum is defined gets #imported. The name of the typedef'd enum. For exemple Gender, if you have typedef NS_ENUM( uint8_t, Gender) { GenderMale, GenderFemale }; (ObjC) or enum Gender : UInt16 { case Male, Female } (Swift)

Note

There may be more valid key-value pairs that aren't documented here.

Clone this wiki locally