Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/CoreData.framework |
Availability | Available in Mac OS X v10.5 and later. |
Companion guide | |
Declared in | NSMappingModel.h |
Instances of NSMappingModel
specify how to map from a source to a destination managed object model.
+ mappingModelFromBundles:forSourceModel:destinationModel:
+ inferredMappingModelForSourceModel:destinationModel:error:
– initWithContentsOfURL:
Returns a newly-created mapping model to migrate data from the source to the destination model.
+ (NSMappingModel *)inferredMappingModelForSourceModel:(NSManagedObjectModel *)source destinationModel:(NSManagedObjectModel *)destination error:(NSError **)error
The source managed object model.
The destination managed object model.
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
.
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
.
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.
NSMappingModel.h
Returns the mapping model to translate data from the source to the destination model.
+ (NSMappingModel *)mappingModelFromBundles:(NSArray *)bundles forSourceModel:(NSManagedObjectModel *)sourceModel destinationModel:(NSManagedObjectModel *)destinationModel
An array of bundles in which to search for mapping models.
The managed object model for the source store.
The managed object model for the destination store.
Returns the mapping model to translate data from sourceModel to destinationModel. If a suitable mapping model cannot be found, returns nil
.
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.
NSMappingModel.h
Returns the collection of entity mappings for the receiver.
- (NSArray *)entityMappings
The collection of entity mappings for the receiver.
The order of the mappings in the array specifies the order in which they will be processed during migration.
NSMappingModel.h
Returns a dictionary of the entity mappings for the receiver.
- (NSDictionary *)entityMappingsByName
A dictionary of the entity mappings for the receiver, keyed by their respective name.
You can use this method to quickly access to mapping by name, rather than iterating the ordered array returned by entityMappings
.
NSMappingModel.h
Returns a mapping model initialized from a given URL.
- (id)initWithContentsOfURL:(NSURL *)url
The location of an archived mapping model.
A mapping model initialized from url.
NSMappingModel.h
Sets the collection of entity mappings for the receiver
- (void)setEntityMappings:(NSArray *)mappings
The collection of entity mappings for the receiver.
The order of the mappings specifies the order in which they will be processed during migration.
NSMappingModel.h
Last updated: 2009-02-03