Class: NSMigrationManager

Inherits:
NSObject show all

Overview

Instances of NSMigrationManager perform a migration of data from one persistent store to another using a given mapping model.

Instance Method Summary (collapse)

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Method Details

- (Object) associateSourceInstance(sourceInstance, withDestinationInstance:destinationInstance, forEntityMapping:entityMapping)

Associates a given source instance with an array of destination instances for a given property mapping. 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.

Parameters:

  • sourceInstance (NSManagedObject)

    A source managed object.

  • destinationInstance (NSManagedObject)

    The destination manage object for sourceInstance.

  • entityMapping (NSEntityMapping)

    The entity mapping to use to associate sourceInstance with the object in destinationInstances.

Returns:

- (Object) cancelMigrationWithError(error)

Cancels the migration with a given error. 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.

Parameters:

  • error (NSError)

    An error object that describes the reason why the migration is canceled.

Returns:

- (NSEntityMapping) currentEntityMapping

Returns the entity mapping currently being processed. Each entity is processed a total of three times (instance creation, relationship creation, validation).

Returns:

- (NSManagedObjectContext) destinationContext

Returns 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.

Returns:

  • (NSManagedObjectContext)

    The managed object context the receiver uses for writing the destination persistent store.

- (NSEntityDescription) destinationEntityForEntityMapping(mEntity)

Returns the entity description for the destination entity of a given entity mapping. Entity mappings do not store the actual description objects, but rather the name and version information of the entity.

Parameters:

Returns:

- (Array) destinationInstancesForEntityMappingNamed(mappingName, sourceInstances:sourceInstances)

Returns the managed object instances created in the destination store for a named entity mapping for a given array of source instances.

Parameters:

  • mappingName (String)

    The name of an entity mapping in use.

  • sourceInstances (Array)

    A array of managed objects in the source store.

Returns:

  • (Array)

    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.

- (NSManagedObjectModel) destinationModel

Returns the destination model for the receiver.

Returns:

- (Object) initWithSourceModel(sourceModel, destinationModel:destinationModel)

Initializes a migration manager instance with given source and destination models. You specify the mapping model in the migration method, migrateStoreFromURL:type:options:withMappingModel:toDestinationURL:destinationType:destinationOptions:error:.

Parameters:

  • sourceModel (NSManagedObjectModel)

    The source managed object model for the migration manager.

  • destinationModel (NSManagedObjectModel)

    The destination managed object model for the migration manager.

Returns:

  • (Object)

    A migration manager instance initialized to migrate data in a store that uses sourceModel to a store that uses destinationModel.

- (NSMappingModel) mappingModel

Returns the mapping model for the receiver.

Returns:

- (Boolean) migrateStoreFromURL(sourceURL, type:sStoreType, options:sOptions, withMappingModel:mappings, toDestinationURL:dURL, destinationType:dStoreType, destinationOptions:dOptions, error:error)

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. This method performs compatibility checks on the source and destination models and the mapping model.

Parameters:

Returns:

  • (Boolean)

    YES if the migration proceeds without errors during the compatibility checks or migration, otherwise NO.

- (Float) migrationProgress

Returns a number from 0 to 1 that indicates the proportion of completeness of the migration.

Returns:

  • (Float)

    A number from 0 to 1 that indicates the proportion of completeness of the migration. If a migration is not taking place, returns 1.

- (Object) reset

Resets the association tables for the migration.

Returns:

- (Object) setUserInfo(dict)

Sets the user info for the receiver. You can use the user info dictionary to aid the customization of your migration process.

Parameters:

  • dict (Hash)

    The user info for the receiver.

Returns:

- (Object) setUsesStoreSpecificMigrationManager(flag)

Sets whether the receiver tries to use a store specific migration manager to perform the migration. A store-specific migration manager class is not guaranteed to perform any of the migration manager delegate callbacks or update values for the observable properties.The default value is YES.

Parameters:

  • flag (Boolean)

    YES to use a store-specific migration manager, otherwise NO.

Returns:

- (NSManagedObjectContext) sourceContext

Returns 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.

Returns:

  • (NSManagedObjectContext)

    The managed object context the receiver uses for reading the source persistent store.

- (NSEntityDescription) sourceEntityForEntityMapping(mEntity)

Returns the entity description for the source entity of a given entity mapping. Entity mappings do not store the actual description objects, but rather the name and version information of the entity.

Parameters:

Returns:

- (Array) sourceInstancesForEntityMappingNamed(mappingName, destinationInstances:destinationInstances)

Returns the managed object instances in the source store used to create a given destination instance for a given property mapping.

Parameters:

  • mappingName (String)

    The name of an entity mapping in use.

  • destinationInstances (Array)

    A array of managed objects in the destination store.

Returns:

  • (Array)

    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.

- (NSManagedObjectModel) sourceModel

Returns the source model for the receiver.

Returns:

- (Hash) userInfo

Returns the user info for the receiver.

Returns:

  • (Hash)

    The user info for the receiver.

- (Boolean) usesStoreSpecificMigrationManager

Returns a Boolean value that indicates whether the receiver tries to use a store specific migration manager to perform the migration. For more discussion, see setUsesStoreSpecificMigrationManager:.

Returns:

  • (Boolean)

    YES if the receiver uses a store-specific migration manager, otherwise NO.