associate(sourceInstance:withDestinationInstance:for:)
Associates a given source managed object instance with an array of destination instances for a given property mapping.
Declaration
func associate(sourceInstance: NSManagedObject, withDestinationInstance destinationInstance: NSManagedObject, for entityMapping: NSEntityMapping)Parameters
- sourceInstance:
A source managed object.
- destinationInstance:
The destination manage object for
sourceInstance. - entityMapping:
The entity mapping to use to associate
sourceInstancewith the object indestinationInstances.
Discussion
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 createDestinationInstances(forSource:in:manager:) method.