Note that there are some explanatory texts on larger screens.

plurals
  1. POImplementation of "Automatic Lightweight Migration" for Core Data (iPhone)
    primarykey
    data
    text
    <p>I would like to make my app able to do an automatic lightweight migration when I add new attributes to my core data model.</p> <p>In the guide from Apple this is the only info on the subject I could find:</p> <blockquote> <p><strong>Automatic Lightweight Migration</strong></p> <p>To request automatic lightweight migration, you set appropriate flags in the options dictionary you pass in addPersistentStoreWithType:configuration:URL:options:error:. You need to set values corresponding to both the NSMigratePersistentStoresAutomaticallyOption and the NSInferMappingModelAutomaticallyOption keys to YES:</p> </blockquote> <pre><code>NSError *error; NSURL *storeURL = &lt;#The URL of a persistent store#&gt;; NSPersistentStoreCoordinator *psc = &lt;#The coordinator#&gt;; NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption, [NSNumber numberWithBool:YES], NSInferMappingModelAutomaticallyOption, nil]; if (![psc addPersistentStoreWithType:&lt;#Store type#&gt; configuration:&lt;#Configuration or nil#&gt; URL:storeURL options:options error:&amp;error]) { // Handle the error. } </code></pre> <p>My <code>NSPersistentStoreCoordinator</code> is initialized in this way:</p> <pre><code>- (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; } NSURL *storeUrl = [NSURL fileURLWithPath: [[self applicationDocumentsDirectory] stringByAppendingPathComponent: @"FC.sqlite"]]; NSError *error = nil; persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]]; if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&amp;error]) { NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } return persistentStoreCoordinator; } </code></pre> <p><strong>I am having trouble seeing where and how I should add the Apple code to get the Automatic Lightweight Migration working?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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