small medium large xlarge

Back to: All Forums  Core Data
07 Nov 2009, 15:19
Matt Crocker (2 posts)

I purchased the Core Data book as I found the Apple documentation somewhat opaque at times, and because the Recipe project is very similar in structure to what I’m trying to create.

Everything’s been going well until I tried to implement automatic migration. For some reason, when I try and open an old file with a newer data model I get the standard error, telling me that the data models are incompatible, rather than triggering the custom error in the persistentStoreCoordinator method and then triggering the mapping methods.

My persistentStoreCoordinator, managedObjectModel and managedObjectContext methods are nearly identical to those in the book, with the exception that my ‘pathForResource’ in managedObjectModel is ‘MyDocument’, rather than ‘DataModel’, reflecting the name of my MOMD file bundle.

Has anybody else encountered a problem like this? I’m sure it’s something pretty elementary…

07 Nov 2009, 15:34
Matt Crocker (2 posts)

Ha! Answered my own question.

The ‘persistentStoreCoordinator’ method is only applicable to a non-document based application. For a document-based app, it’s even easier, as all you have to do is override the ‘configurePersistentStoreCoordinatorForURL’ method, and set the NSMigratePersistentStoresAutomaticallyOption in there instead.

You must be logged in to comment