Binding selectable to-many relationship in IB

  • Hello all,

    First post - taking a stab at learning Core Data and Bindings (As
    with all great learning processes - this one was spawned by me not
    liking any of the invoicing software out there and choosing to roll
    my own).

    Some background on my scenario:

    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?

    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?
    Right now it's printing out an error in my table - my process is to
    tell it simply to bind to the "clients" (to-many) relationship of the
    selected service.  Advice?

    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.

    Thanks in advance for any advice you're able to offer me.  All the best,

    -Aaron
  • 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
previous month september 2007 next month
MTWTFSS
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Go to today