PatrikD
PatrikD

Reputation: 377

objective-c app update and core data

One thing bothers me, I am developing iOS app. Firstly when hasPerformedFirstLaunch I load core data, it works good. But later, when I'll update my app. I would like to change core data. How can I do this or How you do this? It is an app where a lot of data that will accrue updates.

My first launch

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"hasPerformedFirstLaunch"]) {
    [self initialCoreData];
    [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasPerformedFirstLaunch"];
    [[NSUserDefaults standardUserDefaults] synchronize];
}

Upvotes: 2

Views: 95

Answers (2)

Andrea
Andrea

Reputation: 26385

Let's define what are you meaning by "saying change core data".

  • Are you talking about changing the model schema ?
  • or just update your bundled db?

In the first case you should follow the migration procedure of core data, there are a lot of information on how to do it. Basically you have 2 options, the light migration or the heavier one.
In the second case is just easy as change a bundled file, but if you also changed the model scheme you are going to encounter a crash pretty soon.

Upvotes: 2

Stephen Darlington
Stephen Darlington

Reputation: 52565

Core Data has the ability to migrate models from old versions to newer ones automatically, albeit with a few limitations. There's lots of documentation and there are some decent tutorials around if you search for "lightweight migration."

Upvotes: 2

Related Questions