The core data parser accepts a xcdatamodeld
(or xcdatamodel
) file. The parser will load all the configurations, entities, and fetch requests for each model.
The output context has the following structure:
models
:Array
— A list of parsed models, with each:configurations
:Dictionary<String, Array<String>>
— Map of configuration names and the corresponding list of entity namesentities
:Dictionary
– Map of all the entities in the model, each key being the entity's name, and corresponding value is a dictionary described below:name
:String
- Entity nameclassName
:String
- Class name as specified by the user (usually the same asname
)isAbstract
:Bool
- Whether the entity is an abstract or notsuperEntity
:String
- Name of the super (parent) entityuniquenessConstraints
:Array<Array<String>>
- List of uniqueness constraints, each being a list of attributesattributes
:Array
- List of attributes (seeEntity Attribute
)relationships
:Array
- List of relationships (seeEntity Relationship
)fetchedProperties
:Array
- List of fetched properties (seeEntity Fetched Property
)
fetchRequests
:Dictionary
- All fetch requests, grouped by entity. Each key will be an entity name, each value will be a list of corresponding fetch requests (seeFetch Request
)
An Entity Attribute
will have the following properties:
name
:String
- Attribute namecustomClassName
:String
- Custom class name (if one has been defined)isIndexed
:Bool
- Whether the property is indexed or not.isOptional
:Bool
- Whether the property is optional or not.isTransient
:Bool
- Whether the property is transient or not.propertyType
:String
- Property type, will be "attribute"shouldGenerateCode
:Bool
- Whether the template should generate code or not (Xcode will take care of it)type
:String
- Type of the attribute (Transformable, Binary, Boolean, ...)typeName
:String
- Actual attribute type, based on the values fortype
,usesScalarValueType
andcustomClassName
usesScalarValueType
:Bool
- Whether the property should use scalar value types or not.userInfo
:Dictionary
- Dictionary of keys/values defined by the user
An Entity Relationship
will have the following properties:
name
:String
- Relationship namedestinationEntity
:String
- The name of the destination's entity.inverseRelationship
:Dictionary
- The inverse of this relationship:name
:String
: The name of the inverse relationship.destinationEntity
:String
- The name of the inverse relationship's entity.
isIndexed
:Bool
- Whether the property is indexed or not.isOptional
:Bool
- Whether the property is optional or not.isOrdered
:Bool
- Whether the relationship is ordered or unordered.isToMany
:Bool
- Whether the relationship targets one or more instances.isTransient
:Bool
- Whether the property is transient or not.propertyType
:String
- Property type, will be "relationship"userInfo
:Dictionary
- Dictionary of keys/values defined by the user
An Entity Fetched Property
will have the following properties:
name
:String
- Fetched property namefetchRequest
:Dictionary
- The fetch request (seeFetch Request
)isOptional
:Bool
- Whether the property is optional or not.propertyType
:String
- Property type, will be "fetchedProperty"userInfo
:Dictionary
- Dictionary of keys/values defined by the user
A Fetch Request
will have the following properties:
name
:String
- Fetch request nameentity
:String
- Requested entity namefetchBatchSize
:Int
- Request batch sizefetchLimit
:Int
- Request fetch limitincludePropertyValues
:Bool
- Whether to include property values or notincludesPendingChanges
:Bool
- Whether to include pending changes or notincludeSubentities
:Bool
- Whether to include sub-entities or notpredicateString
:String
- Predicate string for filteringresultType
:String
- Type of the fetch resultreturnDistinctResults
:Bool
- Whether to return only the unique results or notreturnsObjectsAsFaults
:Bool
- Whether to return results as faults or notsubstitutionVariables
:Dictionary
- Substitution variables (for thepredicate
), each key being the variable name, and as value the expected type.
models:
- configurations:
Custom:
- "NewEntity"
Default:
- "AbstractEntity"
- "ChildEntity"
- "MainEntity"
- "NewEntity"
- "SecondaryEntity"
entities:
AbstractEntity:
attributes: []
className: "AbstractEntity"
fetchedProperties: []
isAbstract: true
name: "AbstractEntity"
relationships: []
superEntity: ""
uniquenessConstraints: []
userInfo: {}
ChildEntity:
attributes: []
className: "ChildEntity"
fetchedProperties: []
isAbstract: false
name: "ChildEntity"
relationships: []
superEntity: "MainEntity"
uniquenessConstraints: []
userInfo:
key: "value"
MainEntity:
attributes:
- customClassName: "NSAttributedString"
isIndexed: false
isOptional: true
isTransient: false
name: "attributedString"
propertyType: "attribute"
type: "Transformable"
typeName: "NSAttributedString"
userInfo: {}
usesScalarValueType: false
- customClassName: ""
isIndexed: false
isOptional: true
isTransient: false
name: "boolean"
propertyType: "attribute"
type: "Boolean"
typeName: "Bool"
userInfo: {}
usesScalarValueType: true
- customClassName: ""
isIndexed: false
isOptional: true
isTransient: false
name: "float"
propertyType: "attribute"
type: "Float"
typeName: "Float"
userInfo: {}
usesScalarValueType: true
- customClassName: ""
isIndexed: false
isOptional: true
isTransient: false
name: "int64"
propertyType: "attribute"
type: "Integer 64"
typeName: "Int64"
userInfo: {}
usesScalarValueType: true
className: "MainEntity"
fetchedProperties:
- fetchRequest:
entity: "NewEntity"
fetchBatchSize: 0
fetchLimit: 0
includePropertyValues: true
includeSubentities: true
includesPendingChanges: true
name: "fetchedPropertyFetchRequest"
predicateString: "true == true"
resultType: "Object"
returnDistinctResults: false
returnsObjectsAsFaults: true
substitutionVariables: {}
isOptional: true
name: "fetchedProperty"
propertyType: "fetchedProperty"
userInfo:
key: "value"
isAbstract: false
name: "MainEntity"
relationships:
- destinationEntity: "SecondaryEntity"
inverseRelationship:
entityName: "SecondaryEntity"
name: "manyToMany"
isIndexed: false
isOptional: true
isOrdered: false
isToMany: true
isTransient: false
name: "manyToMany"
propertyType: "relationship"
userInfo: {}
superEntity: ""
uniquenessConstraints: []
userInfo:
key: "value"
NewEntity:
attributes:
- customClassName: ""
isIndexed: false
isOptional: true
isTransient: false
name: "identifier"
propertyType: "attribute"
type: "UUID"
typeName: "UUID"
userInfo: {}
usesScalarValueType: false
className: "NewEntity"
fetchedProperties: []
isAbstract: false
name: "NewEntity"
relationships: []
superEntity: "AbstractEntity"
uniquenessConstraints:
- - "identifier"
userInfo: {}
SecondaryEntity:
attributes:
- customClassName: ""
isIndexed: false
isOptional: false
isTransient: false
name: "name"
propertyType: "attribute"
type: "String"
typeName: "String"
userInfo: {}
usesScalarValueType: false
className: "SecondaryEntity"
fetchedProperties: []
isAbstract: false
name: "SecondaryEntity"
relationships:
- destinationEntity: "MainEntity"
inverseRelationship:
entityName: "MainEntity"
name: "manyToMany"
isIndexed: false
isOptional: true
isOrdered: false
isToMany: true
isTransient: false
name: "manyToMany"
propertyType: "relationship"
userInfo: {}
superEntity: ""
uniquenessConstraints: []
userInfo: {}
fetchRequests:
MainEntity:
- entity: "MainEntity"
fetchBatchSize: 0
fetchLimit: 0
includePropertyValues: true
includeSubentities: true
includesPendingChanges: true
name: "ObjectIDFetchRequest"
predicateString: "oneToOne.name == $NAME"
resultType: "Object ID"
returnDistinctResults: false
returnsObjectsAsFaults: true
substitutionVariables:
NAME: "String"