• 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
Re: Core Data migration from xml to sqlite
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Core Data migration from xml to sqlite


  • Subject: Re: Core Data migration from xml to sqlite
  • From: Adam Swift <email@hidden>
  • Date: Wed, 2 Sep 2009 11:30:06 -0700


On Sep 2, 2009, at 4:51 AM, Ian Kennedy wrote:

Hi all,

How would I go about doing a one-time migration of application data from an xml persistent store to a sqlite persistent store? i.e. the model stays the same, the data is migrated, and the app uses the sqlite store from there on out.

I've been unsuccessfully trying to do it inside of the persistentStoreCoordinator method by working with the example from here: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingPersistentStores.html

Here is what I've tried, which doesn't migrate any data, just provides me with an empty sqlite store:

http://pastie.textmate.org/602152


NSPersistentStore *xmlStore = [persistentStoreCoordinator persistentStoreForURL:xmlUrl];
NSPersistentStore *sqliteStore = [persistentStoreCoordinator migratePersistentStore:xmlStore toURL:sqliteUrl options:nil withType:NSSQLiteStoreType error:&error];


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

persistentStoreCoordinator is nil when you attempt the migration.

Code defensively! You should be checking that he xmlStore is non-nil before attempting migration, that the sqliteStore is non nil after migration and presenting the error if one occurs.

Thanks for any help,
Ian
_______________________________________________

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

_______________________________________________

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


References: 
 >Core Data migration from xml to sqlite (From: Ian Kennedy <email@hidden>)

  • Prev by Date: Re: Macros
  • Next by Date: Re: Problem with NSFileManager
  • Previous by thread: Core Data migration from xml to sqlite
  • Next by thread: how to get a managedObjectContext in a nib file
  • Index(es):
    • Date
    • Thread