Wednesday, September 9, 2009

More on Core Data

Here is a correction and clarification on the Core Data problem reported here.

It appears that mergedModelFromBundles: does, in fact, work correctly with versioned managed object models. The problem is that Xcode doesn't clear out the old, non-versioned model when you version your data model, so you end up with both the versioned .momd and the original .mom file in your bundle and it attempts to load both, which is what causes the conflict, not the different versions inside the .momd.

Doing a Clean All should fix the problem, however I've tested this a bit, and sometimes you have to uninstall the app or reset the simulator to fix it, though I haven't isolated why yet.

Personally, I'm going to stick with the solution in the previous post for the time being. By specifying the versioned file explicitly, this can't be a problem either in testing or for your users. If you prefer to use the default template version of managedObjectModel, then make sure you do a Clean All after versioning your data model.

Thanks to Jack Nutting for pointing me in the right direction on this.

No comments:

Post a Comment