Database Reference
In-Depth Information
3.1
Some Maintenance Before We Migrate
Before we actually release a new version of our application that migrates the
data, we need to first complete a minor “maintenance” update for our users.
Normally, we would add this code to the very first version of our application,
but just in case we wrote that first release before versioning was a considera-
tion, we need to go back to our old version and add a very small amount of
code to help our users.
Some users will download the new version of an application to just “try it out”
and see whether it is worth the upgrade price or worth the hassle. Normally
this is not an issue—until we upgrade the data underneath our users. Then
things go sideways. What we do not want to happen is the error message
shown in Figure 6, Default model issue dialog box , on page 38 .
Figure 6—Default model issue dialog box
Note that this is the error message we would see on OS X. On iOS, our
application would simply crash on launch. This is a terrible user experience
and something we want to avoid. Fortunately, the way to avoid it is very easy,
and we can add it to a point release of our application before we do any
migration. That way, when the users open the first version of our application
after “testing” the second version, they get a friendly error message; or we
can take it a step further and restore/access the older version of their data.
Baseline/PPRecipes/PPRAppDelegateAlt2.m
dispatch_async(queue, ^{
NSError *error = nil;
NSPersistentStoreCoordinator *coordinator = nil;
coordinator = [moc persistentStoreCoordinator];
NSPersistentStore *store = nil;
store = [coordinator addPersistentStoreWithType:NSSQLiteStoreType
configuration:nil
URL:storeURL
options:nil
error:&error];
 
 
 
Search WWH ::




Custom Search