Type Method

inferredMappingModel(forSourceModel:destinationModel:)

Returns a newly created mapping model that will migrate data from the source to the destination model.

Declaration

class func inferredMappingModel(forSourceModel sourceModel: NSManagedObjectModel, destinationModel: NSManagedObjectModel) throws -> NSMappingModel

Parameters

source

The source managed object model.

destination

The destination managed object model.

error

If a problem occurs, on return contains an NSInferredMappingModelError error that describes the problem.

The error’s user info will contain additional details about why inferring the mapping model failed (check for the following keys: reason, entity, property.

Return Value

A newly-created mapping model to migrate data from the source to the destination model. If the mapping model can not be created, returns nil.

Discussion

A model will be created only if all changes are simple enough to be able to reasonably infer a mapping (for example, removing or renaming an attribute, adding an optional attribute or relationship, or adding renaming or deleting an entity). Element IDs are used to track renamed properties and entities.

See Also

Creating a Mapping

init?(from: [Bundle]?, forSourceModel: NSManagedObjectModel?, destinationModel: NSManagedObjectModel?)

Returns the mapping model that will translate data from the source to the destination model.

init?(contentsOf: URL?)

Returns a mapping model initialized from a given URL.