NSEntityMapping Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in OS X v10.5 and later. |
| Companion guide | |
| Declared in | NSEntityMapping.h |
Overview
Instances of NSEntityMapping specify how to map an entity from a source to a destination managed object model.
Tasks
Managing Source Information
-
– sourceEntityName -
– setSourceEntityName: -
– sourceEntityVersionHash -
– setSourceEntityVersionHash: -
– sourceExpression -
– setSourceExpression:
Managing Destination Information
-
– destinationEntityName -
– setDestinationEntityName: -
– destinationEntityVersionHash -
– setDestinationEntityVersionHash:
Managing Mapping Information
Instance Methods
attributeMappings
Returns the array of attribute mappings for the receiver.
Return Value
The array of attribute mappings for the receiver.
Special Considerations
The order of mappings in the array specifies the order in which the mappings will be processed during a migration.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hdestinationEntityName
Returns the destination entity name for the receiver.
Return Value
The destination entity name for the receiver.
Discussion
Mappings are not directly bound to entity descriptions. You can use the migration manager’s destinationEntityForEntityMapping: method to retrieve the entity description for this entity name.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hdestinationEntityVersionHash
Returns the version hash for the destination entity for the receiver.
Return Value
The version hash for the destination entity for the receiver.
Discussion
The version hash is calculated by Core Data based on the property values of the entity (see NSEntityDescription’s versionHash method). The destinationEntityVersionHash must equal the version hash of the destination entity represented by the mapping.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hentityMigrationPolicyClassName
Returns the class name of the migration policy for the receiver.
Return Value
The class name of the migration policy for the receiver.
Discussion
If not specified, the default migration class name is NSEntityMigrationPolicy. You can specify a subclass to provide custom behavior.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hmappingType
Returns the mapping type for the receiver.
Return Value
The mapping type for the receiver.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hname
Returns the name of the receiver.
Return Value
The name of the receiver.
Discussion
The name is used only as a means of distinguishing mappings in a model. If not specified, the value defaults to SOURCE->DESTINATION.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hrelationshipMappings
Returns the array of relationship mappings for the receiver.
Return Value
The array of relationship mappings for the receiver.
Special Considerations
The order of mappings in the array specifies the order in which the mappings will be processed during a migration.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetAttributeMappings:
Sets the array of attribute mappings for the receiver.
Parameters
- mappings
The array of attribute mappings for the receiver.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetDestinationEntityName:
Sets the destination entity name for the receiver.
Parameters
- name
The destination entity name.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetDestinationEntityVersionHash:
Sets the version hash for the destination entity for the receiver.
Parameters
- vhash
The version hash for the destination entity.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetEntityMigrationPolicyClassName:
Sets the class name of the migration policy for the receiver.
Parameters
- name
The class name of the migration policy (either
NSEntityMigrationPolicyor a subclass ofNSEntityMigrationPolicy).
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hsetMappingType:
Sets the mapping type for the receiver.
Parameters
- type
The mapping type for the receiver.
Discussion
If you specify a custom entity mapping type, you must specify a value for the migration policy class name as well (see setEntityMigrationPolicyClassName:).
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hsetName:
Sets the name of the receiver.
Parameters
- name
The name of the receiver.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hsetRelationshipMappings:
Sets the array of relationship mappings for the receiver.
Parameters
- mappings
The array of relationship mappings for the receiver.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetSourceEntityName:
Sets the source entity name for the receiver.
Parameters
- name
The source entity name for the receiver.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetSourceEntityVersionHash:
Sets the version hash for the source entity for the receiver.
Parameters
- vhash
The version hash for the source entity for the receiver.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsetSourceExpression:
Sets the source expression for the receiver.
Parameters
- source
The source expression for the receiver. The expression can be a fetch request expression, or any other expression which evaluates to a collection.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hsetUserInfo:
Sets the user info dictionary for the receiver.
Parameters
- dict
The user info dictionary for the receiver.
Discussion
You can set the contents of the dictionary using the appropriate inspector in the Xcode mapping model editor.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hsourceEntityName
Returns the source entity name for the receiver.
Return Value
The source entity name for the receiver.
Discussion
Mappings are not directly bound to entity descriptions; you can use the sourceEntityForEntityMapping: method on the migration manager to retrieve the entity description for this entity name.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsourceEntityVersionHash
Returns the version hash for the source entity for the receiver.
Return Value
The version hash for the source entity for the receiver.
Discussion
The version hash is calculated by Core Data based on the property values of the entity (see NSEntityDescription’s versionHash method). The sourceEntityVersionHash must equal the version hash of the source entity represented by the mapping.
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.hsourceExpression
Returns the source expression for the receiver.
Return Value
The source expression. The expression can be a fetch request expression, or any other expression which evaluates to a collection.
Discussion
The source expression is used to obtain the collection of managed objects to process through the mapping.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.huserInfo
Returns the user info dictionary for the receiver.
Return Value
The user info dictionary.
Discussion
You can use the info dictionary in any way that might be useful in your migration. You set the contents of the dictionary using setUserInfo: or using the appropriate inspector in the Xcode mapping model editor.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.hConstants
Entity Mapping Types
These constants specify the types of entity mapping.
enum {
NSUndefinedEntityMappingType = 0x00,
NSCustomEntityMappingType = 0x01,
NSAddEntityMappingType = 0x02,
NSRemoveEntityMappingType = 0x03,
NSCopyEntityMappingType = 0x04,
NSTransformEntityMappingType = 0x05
};
Constants
NSUndefinedEntityMappingTypeSpecifies that the developer handles destination instance creation.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.NSCustomEntityMappingTypeSpecifies a custom mapping.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.NSAddEntityMappingTypeSpecifies that this is a new entity in the destination model.
Instances of the entity only exist in the destination.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.NSRemoveEntityMappingTypeSpecifies that this entity is not present in the destination model.
Instances of the entity only exist in the source—source instances are not mapped to destination.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.NSCopyEntityMappingTypeSpecifies that source instances are migrated as-is.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.NSTransformEntityMappingTypeSpecifies that entity exists in source and destination and is mapped.
Available in OS X v10.5 and later.
Declared in
NSEntityMapping.h.
Declared In
NSEntityMapping.hNSEntityMappingType
Data type used for constants that specify types of entity mapping.
typedef NSUInteger NSEntityMappingType;
Discussion
For possible values, see “Entity Mapping Types.”
Availability
- Available in OS X v10.5 and later.
Declared In
NSEntityMapping.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-19)