I have an iPhone app that is a complete rewrite of the previous version. But when users get the new version, there are Core Data issues because some of the Entities have similar names. I don't want to use the old datamodel at all.
I looked at SO posts about not merging the datamodels, and instead using initWithContentsOfUrl. However, all the examples say to first grab [NSBundle allBundles] and iterate through this to find my desired DataModel. https://groups.google.com/d/msg/restkit/6_iu2mLOgTo/mjwz2fSmHG4J
Core Data: Error, "Can't Merge Models With Two Different Entities Named 'foo' "
// Look for our managed object model in all of the bundles. (From the app
// it is in the main bundle but not for unit tests.)
NSString *modelPath = nil;
for (NSBundle* bundle in [NSBundle allBundles])
{
modelPath = [bundle pathForResource:@"MyDataModelFilename" ofType:@"momd"];
if (modelPath)
break;
}
NSAssert(modelPath != nil, @"Could not find managed object model.");
NSManagedObjectModel* mom = [[NSManagedObjectModel alloc]
initWithContentsOfURL:[NSURL fileURLWithPath:modelPath]];
objectManager.objectStore =
[RKManagedObjectStore objectStoreWithStoreFilename:_databaseFilename
usingSeedDatabaseName:nil
managedObjectModel:mom
delegate:nil];
However, when I do this, there is only one object in allBundles and that URL is the URL to entire .app file itself, not specific '.xcdatamodeld' files.
So how do I point to a specific '.xcdatamodeld' file? I've tried hardcoding my own URLPath but the allocated MOM is always nil - indicating it couldn't find the model at that URL.