Reputation: 377
I am working on my app and from 1.0 version I added new attributes to entity in core data. So I added new model version, I set up storeURL to Model 6.sqlite
(before Model 5.sqlite) after than edit persistentStoreCoordinator
. But when I run app it crash and log show me error. When I delete app and then install again it works fine. Where can be the problem my app working than hasPerformedFirstLaunch is false initial core data, but I dont wanna lose data every new model version.
Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
NSDictionary *migrateOptions = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
Upvotes: 0
Views: 72
Reputation: 1453
I might be missing something here but what was the need to have a new Model 6.sqlite file. You do not need to have a new persistence store file just because you add a new model version. That's what the migration does, to make the existing persistence store compatible with a new model version.
Upvotes: 1