Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h2>To recap/Full guide:</h2> <ol> <li><p>Before making any change, create a new model version. </p> <p>In Xcode 4: Select your <code>.xcdatamodel</code> -> Editor -> Add Model Version. </p> <p>In Xcode 3: Design -> Data Model -> Add Model Version. </p> <p><em>You will see that a new <code>.xcdatamodel</code> is created in your <strong><code>.xcdatamodeld</code></strong> folder (which is also created if you have none)</em>.</p></li> <li><p>Save.</p></li> <li><p>Select your new <code>.xcdatamodel</code> and make the change you wish to employ in accordance with <a href="http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/vmLightweightMigration.html#//apple_ref/doc/uid/TP40004399-CH4-SW1" rel="noreferrer">the <em>Lightweight Migration</em> documentation</a>.</p></li> <li><p>Save.</p></li> <li><p>Set the current/active schema to the newly created schema. </p> <p>With the <strong><code>.xcdatamodeld</code></strong> folder selected:</p> <p>In Xcode 4: Utilities sidebar -> File Inspector -> Versioned Core Data Model -> Select the new schema. </p> <p>In Xcode 3: Design > Data Model > Set Current Version. </p> <p><em>The green tick on the <code>.xcdatamodel</code> icon will move to the new schema.</em></p></li> <li><p>Save.</p></li> <li><p>Implement the necessary code to perform migration at runtime. </p> <p>Where your <code>NSPersistentStoreCoordinator</code> is created (usually AppDelegate class), for the <code>options</code> parameter, replace <code>nil</code> with the following code:</p> <pre><code>[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil] </code></pre></li> <li><p>Run your app. If there's no crash, you've probably successfully migrated :)</p></li> <li><p>When you have successfully migrated, the migration code (step 7) can be removed. (It is up to the developer to determine when the users of a published app can be deemed to have migrated.)</p></li> </ol> <p><strong>IMPORTANT:</strong> Do not delete old model versions/schemas. Core Data needs the old version to migrate to the new version.</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