| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in Mac OS X v10.5 and later. |
| Companion guide | |
| Declared in | NSEntityMigrationPolicy.h |
Instances of NSEntityMigrationPolicy customize the migration process for an entity mapping.
You set the policy for an entity mapping by passing the name of the migration policy class as the argument to setEntityMigrationPolicyClassName: (typically you specify the name in the Xcode mapping model editor).
– beginEntityMapping:manager:error:
– createDestinationInstancesForSourceInstance:entityMapping:manager:error:
– endInstanceCreationForEntityMapping:manager:error:
– createRelationshipsForDestinationInstance:entityMapping:manager:error:
– endRelationshipCreationForEntityMapping:manager:error:
– performCustomValidationForEntityMapping:manager:error:
– endEntityMapping:manager:error:
Invoked by the migration manager at the start of a given entity mapping.
- (BOOL)beginEntityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the method completes successfully, otherwise NO.
This method is the precursor to the creation stage. In a custom class, you can implement this method to set up any state information that will be useful for the duration of the migration.
– createDestinationInstancesForSourceInstance:entityMapping:manager:error:– endEntityMapping:manager:error:NSEntityMigrationPolicy.hCreates the destination instance(s) for a given source instance.
- (BOOL)createDestinationInstancesForSourceInstance:(NSManagedObject *)sInstance entityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The source instance for which to create destination instances.
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the method completes successfully, otherwise NO.
This method is invoked by the migration manager on each source instance (as specified by the sourceExpression in the mapping) to create the corresponding destination instance(s). It also associates the source and destination instances by calling NSMigrationManager’s associateSourceInstance:withDestinationInstance:forEntityMapping: method.
If you override this method and do not invoke super, you must invoke NSMigrationManager’s associateSourceInstance:withDestinationInstance:forEntityMapping: to associate the source and destination instances as required. .
NSEntityMigrationPolicy.hConstructs the relationships between the newly-created destination instances.
- (BOOL)createRelationshipsForDestinationInstance:(NSManagedObject *)dInstance entityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The destination instance for which to create relationships.
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the relationships are constructed correctly, otherwise NO.
You can use this stage to (re)create relationships between migrated objects—you use the association lookup methods on the NSMigrationManager instance to determine the appropriate relationship targets.
– endInstanceCreationForEntityMapping:manager:error:– endRelationshipCreationForEntityMapping:manager:error:NSEntityMigrationPolicy.hInvoked by the migration manager at the end of a given entity mapping.
- (BOOL)endEntityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the method completes correctly, otherwise NO.
This is the end to the given entity mapping. You can implement this method to perform any clean-up at the end of the migration (from any of the three phases of the mapping).
NSEntityMigrationPolicy.hIndicates the end of the creation stage for the specified entity mapping, and the precursor to the next migration stage.
- (BOOL)endInstanceCreationForEntityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the relationships are constructed correctly, otherwise NO.
You can override this method to clean up state from the creation of destination or to prepare state for the creation of relationships.
– createDestinationInstancesForSourceInstance:entityMapping:manager:error:– createRelationshipsForDestinationInstance:entityMapping:manager:error:NSEntityMigrationPolicy.hIndicates the end of the relationship creation stage for the specified entity mapping.
- (BOOL)endRelationshipCreationForEntityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the method completes correctly, otherwise NO.
This method is invoked after createRelationshipsForDestinationInstance:entityMapping:manager:error:; you can override it to clean up state from the creation of relationships, or prepare state for custom validation in performCustomValidationForEntityMapping:manager:error:.
– createRelationshipsForDestinationInstance:entityMapping:manager:error:– performCustomValidationForEntityMapping:manager:error:NSEntityMigrationPolicy.hInvoked during the validation stage of the entity migration policy, providing the option of performing custom validation on migrated objects.
- (BOOL)performCustomValidationForEntityMapping:(NSEntityMapping *)mapping manager:(NSMigrationManager *)manager error:(NSError **)error
The mapping object in use.
The migration manager performing the migration.
If an error occurs, upon return contains an NSError object that describes the problem.
YES if the method completes correctly, otherwise NO.
This method is called before the default save validation is performed by the framework.
If you implement this method, you must manually obtain the collection of objects you are interested in validating.
NSEntityMigrationPolicy.hKeys used in value expression right hand sides.
NSString *NSMigrationManagerKey; NSString *NSMigrationSourceObjectKey; NSString *NSMigrationDestinationObjectKey; NSString *NSMigrationEntityMappingKey; NSString *NSMigrationPropertyMappingKey; NSString *NSMigrationEntityPolicyKey;
NSMigrationManagerKeyKey for the migration manager.
Available in Mac OS X v10.5 and later.
Declared in NSEntityMigrationPolicy.h.
NSMigrationSourceObjectKeyKey for the source object.
Available in Mac OS X v10.5 and later.
Declared in NSEntityMigrationPolicy.h.
NSMigrationDestinationObjectKeyKey for the destination object.
Available in Mac OS X v10.5 and later.
Declared in NSEntityMigrationPolicy.h.
NSMigrationEntityMappingKeyKey for the entity mapping object.
Available in Mac OS X v10.5 and later.
Declared in NSEntityMigrationPolicy.h.
NSMigrationPropertyMappingKeyKey for the property mapping object.
Available in Mac OS X v10.5 and later.
Declared in NSEntityMigrationPolicy.h.
NSMigrationEntityPolicyKeyKey for the entity migration policy object.
Available in Mac OS X v10.6 and later.
Declared in NSEntityMigrationPolicy.h.
You can use these keys in the right hand sides of a value expression.
NSEntityMigrationPolicy.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-05-01)