---
title: "init(from:forSourceModel:destinationModel:)"
framework: coredata
role: symbol
role_heading: Initializer
path: "coredata/nsmappingmodel/init(from:forsourcemodel:destinationmodel:)"
---

# init(from:forSourceModel:destinationModel:)

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

## Declaration

```swift
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

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

## Discussion

Discussion This method is a companion to the mergedModel(from:) and 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

### Related Documentation

- [Core Data Model Versioning and Data Migration Programming Guide](apple-archive/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html.md)

### Creating a Mapping

- [inferredMappingModel(forSourceModel:destinationModel:)](coredata/nsmappingmodel/inferredmappingmodel(forsourcemodel:destinationmodel:).md)
- [init(contentsOf:)](coredata/nsmappingmodel/init(contentsof:).md)
