Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/CoreData.framework |
Availability | Available in Mac OS X v10.5 and later. |
Companion guide | |
Declared in | NSMigrationManager.h |
Instances of NSMigrationManager
perform a migration of data from one persistent store to another using a given mapping model.
– migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:
– reset
– cancelMigrationWithError:
– associateSourceInstance:withDestinationInstance:forEntityMapping:
– destinationInstancesForEntityMappingNamed:sourceInstances:
– sourceInstancesForEntityMappingNamed:destinationInstances:
Associates a given source instance with an array of destination instances for a given property mapping.
- (void)associateSourceInstance:(NSManagedObject *)sourceInstance withDestinationInstance:(NSManagedObject *)destinationInstance forEntityMapping:(NSEntityMapping *)entityMapping
A source managed object.
The destination manage object for sourceInstance.
The entity mapping to use to associate sourceInstance with the object in destinationInstances.
Data migration is performed as a three-stage process (first create the data, then relate the data, then validate the data). You use this method to associate data between the source and destination stores, in order to allow for relationship creation or fix-up after the creation stage.
This method is called in the default implementation of NSEntityMigrationPolicy
’s createDestinationInstancesForSourceInstance:entityMapping:manager:error:
method.
NSMigrationManager.h
Cancels the migration with a given error.
- (void)cancelMigrationWithError:(NSError *)error
An error object that describes the reason why the migration is canceled.
You can invoke this method from anywhere in the migration process to abort the migration. Calling this method causes migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:
to abort the migration and return error—you should provide an appropriate error to indicate the reason for the cancellation.
NSMigrationManager.h
Returns the entity mapping currently being processed.
- (NSEntityMapping *)currentEntityMapping
The entity mapping currently being processed.
Each entity is processed a total of three times (instance creation, relationship creation, validation).
You can observe this value using key-value observing.
NSMigrationManager.h
Returns the managed object context the receiver uses for writing the destination persistent store.
- (NSManagedObjectContext *)destinationContext
The managed object context the receiver uses for writing the destination persistent store.
This context is created on demand as part of the initialization of the Core Data stacks used for migration.
NSMigrationManager.h
Returns the entity description for the destination entity of a given entity mapping.
- (NSEntityDescription *)destinationEntityForEntityMapping:(NSEntityMapping *)mEntity
An entity mapping.
The entity description for the destination entity of mEntity.
Entity mappings do not store the actual description objects, but rather the name and version information of the entity.
NSMigrationManager.h
Returns the managed object instances created in the destination store for a named entity mapping for a given array of source instances.
- (NSArray *)destinationInstancesForEntityMappingNamed:(NSString *)mappingName sourceInstances:(NSArray *)sourceInstances
The name of an entity mapping in use.
A array of managed objects in the source store.
An array containing the managed object instances created in the destination store for the entity mapping named mappingName for sourceInstances. If sourceInstances is nil
, all of the destination instances created by the specified property mapping are returned.
This method throws an NSInvalidArgumentException
exception if mappingName is not a valid mapping name.
NSMigrationManager.h
Returns the destination model for the receiver.
- (NSManagedObjectModel *)destinationModel
The destination model for the receiver.
NSMigrationManager.h
Initializes a migration manager instance with given source and destination models.
- (id)initWithSourceModel:(NSManagedObjectModel *)sourceModel destinationModel:(NSManagedObjectModel *)destinationModel
The source managed object model for the migration manager.
The destination managed object model for the migration manager.
A migration manager instance initialized to migrate data in a store that uses sourceModel to a store that uses destinationModel.
You specify the mapping model in the migration method, migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:
.
This is the designated initializer for NSMigrationManager
.
Although validation of the models is performed during migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:
, as with NSPersistentStoreCoordinator
once models are added to the migration manager they are immutable and cannot be altered.
NSMigrationManager.h
Returns the mapping model for the receiver.
- (NSMappingModel *)mappingModel
The mapping model for the receiver.
NSMigrationManager.h
Migrates of the store at a given source URL to the store at a given destination URL, performing all of the mappings specified in a given mapping model.
- (BOOL)migrateStoreFromURL:(NSURL *)sourceURL type:(NSString *)sStoreType options:(NSDictionary *)sOptions withMappingModel:(NSMappingModel *)mappings toDestinationURL:(NSURL *)dURL destinationType:(NSString *)dStoreType destinationOptions:(NSDictionary *)dOptions error:(NSError **)error
The location of an existing persistent store. A store must exist at this URL.
The type of store at sourceURL (see NSPersistentStoreCoordinator
for possible values).
A dictionary of options for the source (see NSPersistentStoreCoordinator
for possible values).
The mapping model to use to effect the migration.
The location of the destination store.
The type of store at dURL (see NSPersistentStoreCoordinator
for possible values).
A dictionary of options for the destination (see NSPersistentStoreCoordinator
for possible values).
If an error occurs during the validation or migration, upon return contains an NSError
object that describes the problem.
YES
if the migration proceeds without errors during the compatibility checks or migration, otherwise NO
.
This method performs compatibility checks on the source and destination models and the mapping model.
If a store does not exist at the destination URL (dURL), one is created; otherwise, the migration appends to the existing store.
NSMigrationManager.h
Returns a number from 0
to 1
that indicates the proportion of completeness of the migration.
- (float)migrationProgress
A number from 0
to 1
that indicates the proportion of completeness of the migration. If a migration is not taking place, returns 1
.
You can observe this value using key-value observing.
NSMigrationManager.h
Resets the association tables for the migration.
- (void)reset
This method does not reset the source or destination contexts.
NSMigrationManager.h
Sets the user info for the receiver.
- (void)setUserInfo:(NSDictionary *)dict
The user info for the receiver.
You can use the user info dictionary to aid the customization of your migration process.
NSMigrationManager.h
Returns the managed object context the receiver uses for reading the source persistent store.
- (NSManagedObjectContext *)sourceContext
The managed object context the receiver uses for reading the source persistent store.
This context is created on demand as part of the initialization of the Core Data stacks used for migration.
NSMigrationManager.h
Returns the entity description for the source entity of a given entity mapping.
- (NSEntityDescription *)sourceEntityForEntityMapping:(NSEntityMapping *)mEntity
An entity mapping.
The entity description for the source entity of mEntity.
Entity mappings do not store the actual description objects, but rather the name and version information of the entity.
NSMigrationManager.h
Returns the managed object instances in the source store used to create a given destination instance for a given property mapping.
- (NSArray *)sourceInstancesForEntityMappingNamed:(NSString *)mappingName destinationInstances:(NSArray *)destinationInstances
The name of an entity mapping in use.
A array of managed objects in the destination store.
An array containing the managed object instances in the source store used to create destinationInstances using the entity mapping named mappingName. If destinationInstances is nil
, all of the source instances used to create the destination instance for this property mapping are returned.
This method throws an NSInvalidArgumentException
exception if mappingName is not a valid mapping name.
NSMigrationManager.h
Returns the source model for the receiver.
- (NSManagedObjectModel *)sourceModel
The source model for the receiver.
NSMigrationManager.h
Returns the user info for the receiver.
- (NSDictionary *)userInfo
The user info for the receiver.
NSMigrationManager.h
Last updated: 2009-05-01