Preparing to release an app with coredata
I am coming to an end with the creation of version 1.0 of my new project. first time i use coredata.
the app only uses 1 model, all data will be provided by the user (so I am not loading any data with the app).
of course I am already working on updates for the application in different branches and see some changes to the datamodel in the future. changes to the model will only consist of:
- adding entities
- adding attributes to existing objects
- objects have nothing to do with each other.
I read: iPhone app with CoreData from there I went to: Easy Migration where I read about the ability of coredatas to automatically update their model if the changes are minor (if I read correctly my changes are included there).
in the Java migration doc I found the code for automatic migration:
NSError *error = nil;
NSURL *storeURL = <#The URL of a persistent store#>;
NSPersistentStoreCoordinator *psc = <#The coordinator#>;
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
[NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];
BOOL success = [psc addPersistentStoreWithType:<#Store type#>
configuration:<#Configuration or nil#> URL:storeURL
options:options error:&error];
if (!success) {
// Handle the error.
}
my questions are:
- where would i put this code? i found more info on this
- I'm guessing this code will only be needed in an updated version of the app?
- Do I need any other drugs in my 1.0 app to allow subsequent motives and updates for coredata, or do I not need to think about it in the first release?
source to share
-
I have this code in a method
- (NSPersistentStoreCoordinator *) persistentStoreCoordinator
There should be code like
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
if you let Xcode create the main data methods.
-
This code is only needed in an update that introduces a new model.
-
As far as I know, no. It's all.
source to share