NSMappingModel Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/CoreData.framework |
| Availability | Available in OS X v10.5 and later. |
| Companion guide | |
| Declared in | NSMappingModel.h |
Overview
Instances of NSMappingModel specify how to map from a source to a destination managed object model.
Tasks
Creating a Mapping
-
+ mappingModelFromBundles:forSourceModel:destinationModel: -
+ inferredMappingModelForSourceModel:destinationModel:error: -
– initWithContentsOfURL:
Managing Entity Mappings
Class Methods
inferredMappingModelForSourceModel:destinationModel:error:
Returns a newly-created mapping model to migrate data from the source to the destination model.
Parameters
- source
The source managed object model.
- destination
The destination managed object model.
- error
If a problem occurs, on return contains an
NSInferredMappingModelErrorerror 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.
Availability
- Available in OS X v10.6 and later.
Declared In
NSMappingModel.hmappingModelFromBundles:forSourceModel:destinationModel:
Returns the mapping model to translate data from the source to the destination model.
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 mergedModelFromBundles: and mergedModelFromBundles:forStoreMetadata: methods. In this case, the framework uses the version information from the models to locate the appropriate mapping model in the available bundles.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSMappingModel.hInstance Methods
entityMappings
Returns the collection of entity mappings for the receiver.
Return Value
The collection of entity mappings for the receiver.
Special Considerations
The order of the mappings in the array specifies the order in which they will be processed during migration.
Availability
- Available in OS X v10.5 and later.
Declared In
NSMappingModel.hentityMappingsByName
Returns a dictionary of the entity mappings for the receiver.
Return Value
A dictionary of the entity mappings for the receiver, keyed by their respective name.
Discussion
You can use this method to quickly access to mapping by name, rather than iterating the ordered array returned by entityMappings.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSMappingModel.hinitWithContentsOfURL:
Returns a mapping model initialized from a given URL.
Parameters
- url
The location of an archived mapping model.
Return Value
A mapping model initialized from url.
Availability
- Available in OS X v10.5 and later.
Declared In
NSMappingModel.hsetEntityMappings:
Sets the collection of entity mappings for the receiver
Parameters
- mappings
The collection of entity mappings for the receiver.
Special Considerations
The order of the mappings specifies the order in which they will be processed during migration.
Availability
- Available in OS X v10.5 and later.
See Also
Declared In
NSMappingModel.h© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-02-03)