How to handle this bindings/core data use case?
How to handle this bindings/core data use case?
- Subject: How to handle this bindings/core data use case?
- From: Beau Cronin <email@hidden>
- Date: Wed, 24 Aug 2005 10:23:58 -0400
I'm going to ask this in a pretty general way, since I'm wondering
what the basic approach should be, rather than super-specific walk-
through instructions.
The basic problem is to add _existing_ entities to the target side of
a to-many relationship within a Cocoa UI. The candidates objects are
the set of existing entities in the target side of the relationship.
For example, consider Articles and Authors. Each Article can have
multiple Authors, and each Author can have written multiple Articles,
so this is a many-to-many relationship. I want to assign Authors to
an Article, and I can assume that the Author entities in question
already exist. The question is whether this operation can be done,
through bindings, entirely within Interface Builder.
Right now, I have two separate NSArrayControllers. All_Authors, as
the name implies, controls the array containing all possible authors,
and is simply configured in Entity mode for the Author entity.
Article_Authors, on the other hand, should contain just those Authors
who wrote the current Article. Its contentSet is bound to the
current Article entity's authors property (i.e., the to-many relation
containing the authors of the article). I'm pretty sure that this is
correct so far. Each of these array controllers displays its data in
its own table view, which also works fine.
Now, the tough part. I want to add the current selection(s) of the
All_Authors table/controller to the Article_Authors table/
controller. Eventually, this should work by drag-and-drop, but for
now I'll settle for a simple button push. One problem is that
NSArrayController does not expose an action which allows for the
addition of _existing_ objects, only the insertion of new ones. This
makes me think that I must be going about this in the wrong way.
I suppose that this might require manual coding, but it seems like a
pretty common use case, and I don't want to go to all that effort if
there's a simple solution within the bindings/core data frameworks.
Any suggestions greatly appreciated.
Thanks,
Beau
_______________________________________________
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