really elementary to-many inverse relationship question
really elementary to-many inverse relationship question
- Subject: really elementary to-many inverse relationship question
- From: Matt Neuburg <email@hidden>
- Date: Sat, 02 Dec 2006 16:19:46 -0800
- Thread-topic: really elementary to-many inverse relationship question
I'm initially populating a managed object context "by hand". In my model, a
Stack entity has to-many relationship "backgrounds" to Background, and a
Background entity has a to-one relationship "stack" to Stack. Those
relationships are inverses.
In plain English, a stack can have many backgrounds but a background can
have only one stack.
So I set the background's one stack:
[background setValue: stack forKey: @"stack"];
That works, as I can see through logging. But I also see that the stack has
no backgrounds.
So the inverse relationship is not being updated automatically. My question
is: why not? It says right in the docs that it should be:
"Most relationships are inherently bidirectional. Any changes made to the
relationships between objects should maintain the integrity of the object
graph. Provided that you have correctly modeled a relationship in both
directions and set the inverses, modifying one end of a relationship
automatically updates the other end."
So is that just not true? I'm perfectly willing to populate both ends of the
relationship myself, and I am having no difficulty doing so, like this:
[[stack mutableSetValueForKey:@"backgrounds"] addObject: background];
I don't mind doing that, but shouldn't I not have to? Thx - m.
--
matt neuburg, phd = email@hidden, http://www.tidbits.com/matt/
pantes anthropoi tou eidenai oregontai phusei
AppleScript: the Definitive Guide - Second Edition!
http://www.amazon.com/gp/product/0596102119
Take Control of Word 2004, Tiger, and more -
http://www.takecontrolbooks.com/tiger-customizing.html
Subscribe to TidBITS! It's free and smart. http://www.tidbits.com/
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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