migrating my database to a new model, change model url to one with new name?

I have changed my apps model a bit compared to the last release. I am going to use lightweight migration. I added a new model version and selected it as the model to be used in 'Model Version' in File inspector of the model.


I want to know if I should also change the name of the model from OldModelName to NewModelName in line 6 (below) where I generate the URL for the model, when initializing the stack for the first time...


- (NSManagedObjectModel *)managedObjectModel
{
    if (_managedObjectModel != nil) {
        return _managedObjectModel;
    }
    NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"OldModelName" withExtension:@"momd"];
    _managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
    return _managedObjectModel;
}



Neerav

Replies

If you're using a model bundle that contains both models (both the new one and the old one, with the new one set to the current version) then you specify that model bundle. So there shouldn't be a difference between "OldModelName" and "NewModelName".

You did add the new model to the momd bundle, right?

I chose Editor>Add Model Version

That should have added the model to the existing momd bundle. So nothing to change for the resource name.