R – Cocoa core data self referential interface builder question

cocoacocoa-bindingscore-datainterface-builderself-reference

I'm having trouble understanding how to get the following working in interface builder.

I've created a Core Data model class "Person" that has a number of attributes (first name, surname, etc.) and a relationship to other persons (friends).

Conceptually this is very simple. However figuring out how to get this working in IB is proving tricky.

I've created an interface that has a table down the left side of the window listing all people. On the right side are the fields for inputting a persons details.

I'd like to have a smaller table that shows the "friends" on the right side together with add and remove buttons. Clicking the add button will launch a small panel with searching functionality for filtering the list down so that you can select one person who will then be added to the "friends" set.

Can anyone give me some suggestions or point me at an example I can see that does something like this?

Thanks in advance,
Matt

Best Answer

Assuming you already have an array controller holding the all the people, make a second array controller whose content array is bound to the first controller's selection.friends. Connect the add and remove buttons to this controller's actions, and bind the friends table's column(s) to its arrangedObjects property.

Related Topic