Re: Binding selectable to-many relationship in IB
Re: Binding selectable to-many relationship in IB
- Subject: Re: Binding selectable to-many relationship in IB
- From: mmalc crawford <email@hidden>
- Date: Sun, 16 Sep 2007 19:41:33 -0700
On Sep 16, 2007, at 6:15 PM, Aaron McFarlane wrote:
First post - taking a stab at learning Core Data and Bindings
As has been said so many times on the list now: don't.
Learn one, then the other: <http://developer.apple.com/documentation/Cocoa/Conceptual/CoreData/Articles/cdBeforeYouStart.html#//apple_ref/doc/uid/TP40004318-SW2
>.
I have clients and services. A client has multiple services, and a
service can have multiple clients (I teach music - sometimes group
lessons). This is a many-to-many, inverse relationship, correct?
It's inverse if you've set up the inverse.
I have a tableview that shows the services. Each column represents
a property of my service entity. First question: How do I get IB to
show me the array of clients that correspond to a specific service?
Add an array controller whose contentSet is bound to the clients
relationship of the selection of the services array controller.
Secondly, I wanted to ask for advice as to the path of least
resistance to providing a UI to selecting multiple clients for a
service. I thought that a tokenfield would be nice, but it seems
complicated. My next thought was a tableview with checkboxes as a
column. I have no idea how to approach either of these ideas - any
advice on a similar situation would be greatly appreciated.
If you want to use checkboxes, then add an array controller to manage
*all* the Clients, then for the checkbox column use the standard data
source methods to get/set the value for the checkbox column (return
YES from tableView:objectValueForTableColumn:row: if the client at
<row> is in the clients relationship of the currently-selected
service; if the value passed in to
tableView:setObjectValue:forTableColumn:row: is YES, add the client at
<row> to the clients relationship of the currently-selected service if
it's absent, etc.).
mmalc
_______________________________________________
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