Database Reference
In-Depth Information
{
return YES;
}
@end
The last thing that we need to do is to tell the manager about the association.
Since the manager keeps track of all associations between the two NSManage-
dObjectContext objects, we need to inform it of this new entity that was just
created and that it is associated with the source entity that was passed in.
Once that is complete, we return YES , and we are done.
createRelationshipsForDestinationInstance:
In a properly designed data model, this method will rarely, if ever, be needed.
The intention of this method (which is called in the second pass) is to build
any relationships for the new destination entity that was created in the previ-
ous method. However, if all the relationships in the model are double-sided,
this method is not necessary because we already set up one side of them. If
for some reason there is an entity in the model that is not double-sided,
additional code would be required in this method to handle the one-sided
relationship. Since we do not need that functionality in our model, we just
return YES .
RecipesV3/PPRecipes/RecipeIngredientToIngredient.m
- (BOOL)createRelationshipsForDestinationInstance:(NSManagedObject*)dInstance
entityMapping:(NSEntityMapping*)mapping
manager:(NSMigrationManager*)manager
error:(NSError**)error
{
return YES;
}
If you are thinking this is a lot of work for migration, well, you're right. Man-
ual migrations require a great deal of effort on the part of the developer, and
there isn't a lot of benefit to doing one. This, plus their poor performance, is
the reason for my recommendation to avoid them at nearly any cost. However,
no matter how hard we try to avoid it, sometimes heavy migration is the only
answer. Fortunately, as we just examined, the option is available.
3.5
Fundamentals of Core Data Versioning
We've seen the nuts and bolts, but what's the magic behind all of this? How
does the data migration actually work? As we already explored in the previous
chapters, Core Data works with MOM ( NSManagedObjectModel ) objects that
describe the data entities, their attributes, and their relationships. Core Data
 
 
 
Search WWH ::




Custom Search