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.



4 comments:

Jim said...

Well, this worked on 10.6 but doesn't now. Can't figure out why. Can't remember if I updated to 10.6.1 and then light migration broke or not.

Jim said...

OK, so mmalc pointed out the Light Migration guide and my experience with mmalc is that his referrals are not trivial.

I obviously didn't read the Core Data Light Migration docs with eyes wide open.

Light migration works for the following:

1. New attribute
2. Change existing attribute to optional, no default value.
3. Change existing attribute to not optional, and I must add a default value.

So my last question is, when adding a New Attribute to a new xcdatamodel current version, if I de-select optional, but give no default value, it should barf, as it did for me?

Edwin said...

scrub m65 kamagra attorney lawyer body scrub field jacket lovegra marijuana attorney injury lawyer

h4ns said...

What youre saying is completely true. I know that everybody must say the same thing, but I just think that you put it in a way that everyone can understand. I also love the images you put in here. They fit so well with what youre trying to say. Im sure youll reach so many people with what youve got to say.

Arsenal vs Huddersfield Town live streaming
Arsenal vs Huddersfield Town live streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Wolverhampton Wanderers vs Stoke City Live Streaming
Notts County vs Manchester City Live Streaming
Notts County vs Manchester City Live Streaming
Bologna vs AS Roma Live Streaming
Bologna vs AS Roma Live Streaming
Juventus vs Udinese Live Streaming
Juventus vs Udinese Live Streaming
Napoli vs Sampdoria Live Streaming
Napoli vs Sampdoria Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
Fulham vs Tottenham Hotspur Live Streaming
AS Monaco vs Marseille Live Streaming
AS Monaco vs Marseille Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Alajuelense vs Perez Zeledon Live Streaming
Technology News | News Today | Live Streaming TV Channels