• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CoreData Migration Problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CoreData Migration Problems


  • Subject: CoreData Migration Problems
  • From: Gordon Apple <email@hidden>
  • Date: Tue, 08 Feb 2011 14:08:04 -0600
  • Thread-topic: CoreData Migration Problems

I am trying to migrate an existing app CoreData database to a new version.
Theoretically, this should be what's called a simple migration.  I have not
been able to get it to work.  Just to see what it's trying to do, I went
ahead and let it generate a mapping model, which appears to be correct.  But
somehow, it is apparently not reading the original database.  The following
returns nil.

- (NSPersistentStoreCoordinator*)persistentStoreCoordinator {
    if (persistentStoreCoordinator != nil)
        return persistentStoreCoordinator;

    NSURL *storeUrl = [NSURL fileURLWithPath: [[[self class]
appStorageDirectory] stringByAppendingPathComponent: @"myApp.sqlite"]];

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

    persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc]
initWithManagedObjectModel: self.managedObjectModel];

    NSError *error = nil;
    NSPersistentStore* store =
    [persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType
                                             configuration:nil
                                                       URL:storeUrl
                                                   options:options
                                                     error:&error];
    if(store != nil)
        return persistentStoreCoordinator;    //    Normal exit.

// Error handling...
    return nil;
}

I've read the docs (multiple times) and two books.  I am wondering if I
inadvertently changed some minor thing in the original, getting a different
hash value.

I am confused about some things going on behind-the scenes.  The project
folder contains only the xcdatamodeld file (the compiled version), not the
original xcdatamodel shown in the project listing.  Also, for the main
entity, somewhere along the way, the project folder has picked up a folder
labled "Model-1.moved-aside", which does not show up in the project window.
Is this something needed in the migration?  I'm about at my wit's end with
this thing.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CoreData Migration Problems
      • From: Felix Franz <email@hidden>
    • Re: CoreData Migration Problems
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: why does UIScrollView call layoutSubviews every time it scrolls?
  • Next by Date: Re: CoreData Migration Problems
  • Previous by thread: Re: why does UIScrollView call layoutSubviews every time it scrolls?
  • Next by thread: Re: CoreData Migration Problems
  • Index(es):
    • Date
    • Thread