<!--
{
  "availability" : [
    "iOS: 3.0.0 -",
    "iPadOS: 3.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.5.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSMappingModel/init(from:forSourceModel:destinationModel:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSMappingModel(cm)mappingModelFromBundles:forSourceModel:destinationModel:"
  },
  "title" : "init(from:forSourceModel:destinationModel:)"
}
-->

# init(from:forSourceModel:destinationModel:)

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

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

## Parameters

`bundles`

An array of bundles in which to search for mapping models.

`sourceModel`

The managed object model for the source store.

`destinationModel`

The managed object model for the destination store.

## Return Value

Returns the mapping model to translate data from `sourceModel` to `destinationModel`. If a suitable mapping model cannot be found, returns `nil`.

## Discussion

This method is a companion to the [`mergedModel(from:)`](/documentation/CoreData/NSManagedObjectModel/mergedModel(from:)) and [`mergedModel(from:forStoreMetadata:)`](/documentation/CoreData/NSManagedObjectModel/mergedModel(from:forStoreMetadata:)) methods. In this case, the framework uses the version information from the models to locate the appropriate mapping model in the available bundles.

## See Also

  [Core Data Model Versioning and Data Migration Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html#//apple_ref/doc/uid/TP40004399)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)