Hi,
I have two models at my project, I want to allow versions to one of them. Here's what I did:
- Selected the modelOne.xcdatamodel then Design > Data Model > Add Model Version.
- Clicked command + i then add version to modelOne.xcdatamodel inside modelOne.xcdatamodeld
- Modified modelOne.xcdatamodel, just added some attribute.
At the delegate I added the options dictionary to the NSPersistentStoreCoordinator, and I get the NSManagedObjectModel by merging the two models like:
NSString *path1 = [[NSBundle mainBundle] pathForResource:@"modelOne" ofType:@"momd"]; NSURL *momURL1 = [NSURL fileURLWithPath:path1]; NSManagedObjectModel *modelOne = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL1]; NSString *path2 = [[NSBundle mainBundle] pathForResource:@"modelTwo" ofType:@"mom"]; NSURL *momURL2 = [NSURL fileURLWithPath:path2]; NSManagedObjectModel *modelTwo = [[NSManagedObjectModel alloc] initWithContentsOfURL:momURL2]; NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel modelByMergingModels:[NSArray arrayWithObjects:modelOne, modelTwo, nil]];
Last I did a clean and build, I got error about 'Can't find model for source store'.
Any idea how I could fix this? (Note: if I just use mergedModelFromBundles, I got another error about 'Can't merge models with two different entities named Entity1'