Skip to content

Core Data User Info Keys

Nolan Waite edited this page Jun 29, 2021 · 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. See also Using enums as types The exact name of the file to #import (including the .h extension)
documentation Set this key to emit a documentation comment for the class. This key's value becomes the first paragraph in that comment and appears in Xcode's Quick Help as the Summary. Your desired summary.
discussion If documentation is also set, this key's value becomes the second paragraph of the class's documentation comment and appears in Xcode's Quick Help as the Discussion. Your desired discussion.

Attribute Key-Value Pairs

Key Description Values
mogenerator.readonly Make this generated @property readonly YES, NO
attributeTransformableProtocols Protocols adopted by a transformable property. (Objective-C generated code only) Comma separated list of protocols.
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). See also Using enums as types. The name of the typedef'd enum.
documentation Set this key to emit a documentation comment for the attribute. This key's value becomes the first paragraph in that comment and appears in Xcode's Quick Help as the Summary. Your desired summary.
discussion If documentation is also set, this key's value becomes the second paragraph of the attribute's documentation comment and appears in Xcode's Quick Help as the Discussion. Your desired discussion.

Note

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