Class

NSMigrationManager

A migration manager instance that performs a migration of data from one persistent store to another using a given mapping model.

Topics

Initializing a Manager

init(sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel)

Initializes a migration manager instance with given source and destination models.

Performing Migration Operations

func migrateStore(from: URL, sourceType: String, options: [AnyHashable : Any]? = nil, with: NSMappingModel?, toDestinationURL: URL, destinationType: String, destinationOptions: [AnyHashable : Any]? = nil)

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

func reset()

Resets the association tables for the migration.

func cancelMigrationWithError(Error)

Cancels the migration with a given error.

Monitoring Migration Progress

var migrationProgress: Float

A number between 0 and 1 that indicates the proportion of completeness of the migration.

var currentEntityMapping: NSEntityMapping

The entity mapping currently being processed.

Working with Source and Destination Instances

func associate(sourceInstance: NSManagedObject, withDestinationInstance: NSManagedObject, for: NSEntityMapping)

Associates a given source managed object instance with an array of destination instances for a given property mapping.

func destinationInstances(forEntityMappingName: String, sourceInstances: [NSManagedObject]?)

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

func sourceInstances(forEntityMappingName: String, destinationInstances: [NSManagedObject]?)

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

Getting Information About a Migration Manager

var mappingModel: NSMappingModel

The mapping model for the migration manager.

var sourceModel: NSManagedObjectModel

The source model for the migration manager.

var destinationModel: NSManagedObjectModel

The destination model for the migration manager.

func sourceEntity(for: NSEntityMapping)

Returns the entity description for the source entity of a given entity mapping.

func destinationEntity(for: NSEntityMapping)

Returns the entity description for the destination entity of a given entity mapping.

var sourceContext: NSManagedObjectContext

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

var destinationContext: NSManagedObjectContext

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

var userInfo: [AnyHashable : Any]?

The user info for the migration manager.

Using Store-Specific Migration Managers

var usesStoreSpecificMigrationManager: Bool

A Boolean value that indicates whether the migration manager tries to use a store specific migration manager to perform the migration.

Relationships

Inherits From

Conforms To

See Also

Entity Mapping

class NSMappingModel

A model instance that specifies how to map a model from a source to a destination managed object model.

class NSEntityMapping

A mapping instance that specifies how to map an entity from a source to a destination managed object model.

class NSEntityMigrationPolicy

A policy instance that customizes the migration process for an entity mapping.

enum NSEntityMappingType

Data type used for constants that specify types of entity mapping.

class NSPropertyMapping

A mapping instance that specifies in a model how to map from a property in a source entity to a property in a destination entity.