0

I have a project that uses the same xcdatamodel file as another project. In fact it's the exact same file. I copied it from one project to the other. I also copied the object files over with a few modifications and put them in a static library that the second project now references. These xcdatamodel and object files work just fine in the original project

In the second project, when the objects are saved the relationships between the objects are not saved. While the app is running the relationships are there as expected, pointers are still in memory but when I exit the app, come back in, then do a fetch on the objects, I get the correct number of objects but all their attributes are nil. The attributes are also managed objects that are in the same context. As far as I can tell from looking at the sqlite DB all the objects are there they just don't point at each other.

EDIT: I am using Xcode 3.2.6

TechZen
  • 64,370
  • 15
  • 118
  • 145
iHorse
  • 491
  • 1
  • 5
  • 14
  • You say all the "attributes are nil" and that "The attributes are also managed objects..." Did you mean "relationships" instead of "attributes"? There is a difference. – TechZen Jun 23 '11 at 18:57
  • yea i realized that after i made this post. by attributes i mean member variables of the objects i get back. but really both attributes and relationships are coming back as nil. – iHorse Jun 23 '11 at 21:58
  • If the attributes are nil, how do you know that the objects in the store are the same as the one's in memory? Have you tried getting their managed object ids and checking the next time the app launches? – TechZen Jun 23 '11 at 22:15
  • little bit of an assumption. ive looked at the sqlite file and i can see that the objects are indeed in there they just dont seem to point at each other. when i do the fetch i get the correct number of objects in the array. i am assuming these are the same objects that where there before i exited the app. – iHorse Jun 24 '11 at 16:08

1 Answers1

0

I assume you are doing all this in Xcode 4.

In my experience, I have found it to be extremely buggy using Core Data. Although I am not sure it will fix your problem, you might want to use Xcode 3 to manage this. If you don't have it, here is a torrent. I was having trouble with Xcode 4 so I use Xcode 3 to get my Core Data stuff set up, and then once its set up, I use Xcode 4 for everything else.

Josh Sherick
  • 2,161
  • 3
  • 20
  • 37