Re: Core Data "Uniqueing" not happening as expected
Re: Core Data "Uniqueing" not happening as expected
- Subject: Re: Core Data "Uniqueing" not happening as expected
- From: Quincey Morris <email@hidden>
- Date: Sun, 21 Jun 2009 09:55:48 -0700
On Jun 21, 2009, at 06:26, Jerry Krinock wrote:
My object graph in a Core Data document-based app shows the
following relationship.
Foo <<--> Bar
I insert a single Bar and two Foos, then
[foo1 setBar:bar] ;
[foo2 setBar:bar] ;
Save the document. [1]
Fetch all Bars.
Expected result: An array containing one Bar.
Actual result: An array containing two Bars that have the same
attributes, one related to foo1, the other related to foo2.
Am I reading the documentation incorrectly? How can I make
"uniqueing" happen?
I think there are 2 flaws in your analysis.
First, you *seem* to be suggesting that uniquing is a process of
winnowing away unwanted duplicate objects, but I'm pretty sure that
Core Data doesn't create duplicate objects. Rather, it seems likely
that it uses the object UID to find out if a needed object exists
before ever creating it.
Second, "Fetch all Bars" isn't a scenario where spurious duplicate
Bars could be created. "Fetch all Foos" -- maybe (if I'm wrong on the
previous point).
IAC, it'd be worth trying "Fetch all Foos" to see whether you have 2
or more Foos. Also, you could examine the UIDs of foo1, foo2 and bar
before and after the save, as well as after the fetch. Unless you can
see 2 different objects with the same UID, then it would seem that the
unwanted Bar was actually created as a result of your code somewhere.
_______________________________________________
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