Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It sounds like our model is pretty simple. If all that you are doing is adding a couple more attributes to an existing model, you can do lightweight migration. This means that CoreData will perform the migration for you.</p> <p>Do the following:<br> 1. In Xcode, click on your model. it should have have the .xcdatamodeld extension. 2. Go to Editor->Model Version and add a new model, taking care to change the version. 3. Add the new attributes. 4. Make sure you add the new attributes to the relevant managed object subclasses. 5. in your Persistent Store Coordinator implementation, most likely in your app delegate. Make sure you add the option NSMigratePersistentStoresAutomaticallyOption. Your code should look something like this: </p> <pre><code>NSPersistentStoreCoordinator *psc=persistentStoreCoordinator; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption,nil]; NSError *error=nil; if (![psc addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:options error:&amp;error]) { // handle errors } </code></pre> <p>Here are Apple's docs on lightweight migration <a href="http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweight.html" rel="nofollow">http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweight.html</a></p> <p>Good luck1</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload