Home - Apps - Contact Us - Forum - Advertise - Submit App

Poker Track Pro
 
Register
User:
Pass:
Browse, Rate and Review the best iPhone apps!
 
 
  Book  
  Books  
  Business  
  Catalogs  
  Education  
  Entertainment  
  Finance  
  Food  
  Games  
  Graphics & Design  
  Health  
  Lifestyle  
  Medical  
  Music  
  Navigation  
  News  
  Photography  
  Productivity  
  Reference  
  Social  
  Sports  
  Travel  
  Utilities  
  Weather  
 
AT&T 10:06:06 AM
iphone - Development


Core Data Migration
This is the definitive guide on core data migration. Core data has some big benefits but it has a sinlge big gotcha that gives people a lot of headaches: If you change the schema at all, your app will crash. The solution is Core Data Migration, but if you go to the apple docs or any blog on the net, you will get quickly confused. Until now. These simple steps will fix your problems.

This first thing to know about core data migration is avoid all Apple documentation. It will only confuse you.

This guide will work for just about all migration needs, light, heavy, big, small you name it.

Step 1:

  • Click on your .xcdatamodel file (the one shows your database schema in visual form)
  • Click "Design" --> "Data Model" --> "Add Model Version"

    Step 2:

  • Make changes to the new model
  • Compile and run your app to verify that it still works (using the old model)

    Step 3:

  • Click on your .xcdatamodel file (New one)
  • Click "Design" --> "Data Model" --> "Set Current Version"

    Step 4:

  • click on your main AppDelegate.m file.
  • search for "addPersistentStoreWithType"
  • replace that code with this code:

    NSDictionary* options = [NSDictionary dictionaryWithObjectsAndKeys:
    [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,
    [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil];

    [persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error];

  • This it! Compile your code and it should work fine using the new schema.
  •   Home  
      Apps  
      Contact Us  
      Forum  
      Advertise  
      Submit App  
     © 2011 appdigity.com. All rights reserved.Terms of UsePrivacy Policy;