I have a Core Data Database in my app using UIManagedDocument, and added a new version on top on an old one.
The new version works no problem if I'm adding new Entity without altering old Entity. But once I added a new attribute to an existing Entity of the old version. UIManagedDocument crashed at the point initWithFileURL was called. Here's how I created the UIManagedDocument.
UIManagedDocument *document = [[UIManagedDocument alloc] initWithFileURL:databaseURL];
self.databaseDocument = document;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
self.databaseDocument.persistentStoreOptions = options;
Seems like it crashed at modelByMergingModels called while initWithFileURL
I know this is the line of code that crashed because of the exception breakpoint.
If I delete the newly added attribute, create the NSManagedObject again. The code runs no problem again.
Any hints why is it failing? Any idea will be appreciated.