Use a NSTableView to create / delete relationships

Hello,

In my Core Data application, I have a single “Person” entity with one attribute (“name”) and one relationship “persons”, which is in many-to-many relation with Person (reflexive relation).

My idea was to “link” a Person to another Person. When A is linked to B, B is automatically linked to A. But how to do this?

I have one NSTableView (NSTableViewController Persons) whose single column is bound to Person.name. I can add or delete objects, this is trivial.

I have a second NSTableView (NSTableViewController Links) whose Content Set is Persons.selection.persons. This is OK too.

Now, how can I add or remove relationships with this Links controller? How can I set it? Say, Person A is selected in the NSTableViewController Persons. I suppose I can add an item into the NSTableViewController Links with a (+) button, and then choose the linked person from a NSPopMenuCell.

But now I am into a binding nightmare. Or maybe I should subclass Person and intercept the (+) action do set the relationship by code?

I really need some help! Thanks!