Re: CoreData to-many relationships
Re: CoreData to-many relationships
- Subject: Re: CoreData to-many relationships
- From: mmalcolm crawford <email@hidden>
- Date: Sat, 21 May 2005 11:10:45 -0700
On May 21, 2005, at 10:48 AM, August Trometer wrote:
I have 2 Entities, mailbox and message. Each has various
attributes. I've also defined relationships between the two, so
mailbox to message is a to-many relationship and message to mailbox
is a one to one relationship.
Now, in IB, I'm trying to set things up similar to Mail.app. I have
a table of mailboxes. I also have a table of messages. My mailboxes
controller is bound to the AppDelegate/managedObjectContext, as is
mailboxes.
I can add to and remove from both of these just fine. However, it
seems that the messages are not tied to the selected mailbox. The
message table always lists all messages, not messages for a
particular mailbox. In the application's XML data, there is no
indication that any such relationship is being saved, so I don't
think my mistake is in IB.
At a guess since you don't provide much detail on how you've actually
configured things, you haven't bound the contentSet for the messages
array controller to the relationship from the selection in the
mailboxes controller.
In other words, the mistake is in IB -- you've simply set up two
independent collections and never actually "tied them together". See
<http://developer.apple.com/documentation/Cocoa/Conceptual/
NSPersistentDocumentTutorial/04_Department/chapter_5_section_4.html#//
apple_ref/doc/uid/TP40001799-CH223-DontLinkElementID_28> for an
example of adding objects to a relationship. The fact that the
example has a single department rather than an array of departments
is not relevant -- the principle is the same.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden