Mac OS X Reference Library Apple Developer
Search

NSEntityMapping Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/CoreData.framework
Availability
Available in Mac 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

Managing Destination Information

Managing Mapping Information

Instance Methods

attributeMappings

Returns the array of attribute mappings for the receiver.

- (NSArray *)attributeMappings

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

destinationEntityName

Returns the destination entity name for the receiver.

- (NSString *)destinationEntityName

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

destinationEntityVersionHash

Returns the version hash for the destination entity for the receiver.

- (NSData *)destinationEntityVersionHash

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

entityMigrationPolicyClassName

Returns the class name of the migration policy for the receiver.

- (NSString *)entityMigrationPolicyClassName

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

mappingType

Returns the mapping type for the receiver.

- (NSEntityMappingType)mappingType

Return Value

The mapping type for the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

name

Returns the name of the receiver.

- (NSString *)name

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 Mac OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.h

relationshipMappings

Returns the array of relationship mappings for the receiver.

- (NSArray *)relationshipMappings

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setAttributeMappings:

Sets the array of attribute mappings for the receiver.

- (void)setAttributeMappings:(NSArray *)mappings

Parameters
mappings

The array of attribute mappings for the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setDestinationEntityName:

Sets the destination entity name for the receiver.

- (void)setDestinationEntityName:(NSString *)name

Parameters
name

The destination entity name.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setDestinationEntityVersionHash:

Sets the version hash for the destination entity for the receiver.

- (void)setDestinationEntityVersionHash:(NSData *)vhash

Parameters
vhash

The version hash for the destination entity.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setEntityMigrationPolicyClassName:

Sets the class name of the migration policy for the receiver.

- (void)setEntityMigrationPolicyClassName:(NSString *)name

Parameters
name

The class name of the migration policy (either NSEntityMigrationPolicy or a subclass of NSEntityMigrationPolicy).

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setMappingType:

Sets the mapping type for the receiver.

- (void)setMappingType:(NSEntityMappingType)type

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setName:

Sets the name of the receiver.

- (void)setName:(NSString *)name

Parameters
name

The name of the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.h

setRelationshipMappings:

Sets the array of relationship mappings for the receiver.

- (void)setRelationshipMappings:(NSArray *)mappings

Parameters
mappings

The array of relationship mappings for the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setSourceEntityName:

Sets the source entity name for the receiver.

- (void)setSourceEntityName:(NSString *)name

Parameters
name

The source entity name for the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setSourceEntityVersionHash:

Sets the version hash for the source entity for the receiver.

- (void)setSourceEntityVersionHash:(NSData *)vhash

Parameters
vhash

The version hash for the source entity for the receiver.

Availability
  • Available in Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setSourceExpression:

Sets the source expression for the receiver.

- (void)setSourceExpression:(NSExpression *)source

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

setUserInfo:

Sets the user info dictionary for the receiver.

- (void)setUserInfo:(NSDictionary *)dict

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 Mac OS X v10.5 and later.
See Also
Declared In
NSEntityMapping.h

sourceEntityName

Returns the source entity name for the receiver.

- (NSString *)sourceEntityName

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

sourceEntityVersionHash

Returns the version hash for the source entity for the receiver.

- (NSData *)sourceEntityVersionHash

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

sourceExpression

Returns the source expression for the receiver.

- (NSExpression *)sourceExpression

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

userInfo

Returns the user info dictionary for the receiver.

- (NSDictionary *)userInfo

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h

Constants

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
NSUndefinedEntityMappingType

Specifies that the developer handles destination instance creation.

Available in Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

NSCustomEntityMappingType

Specifies a custom mapping.

Available in Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

NSAddEntityMappingType

Specifies that this is a new entity in the destination model.

Instances of the entity only exist in the destination.

Available in Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

NSRemoveEntityMappingType

Specifies 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 Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

NSCopyEntityMappingType

Specifies that source instances are migrated as-is.

Available in Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

NSTransformEntityMappingType

Specifies that entity exists in source and destination and is mapped.

Available in Mac OS X v10.5 and later.

Declared in NSEntityMapping.h.

Declared In
NSEntityMapping.h

NSEntityMappingType

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 Mac OS X v10.5 and later.
Declared In
NSEntityMapping.h



Last updated: 2009-02-19

Did this document help you? Yes It's good, but... Not helpful...