PDA

View Full Version : To-Many relationship set via lookup table - How?




AussieSusan
Aug 2, 2008, 10:39 PM
I have a core data table that represents radios called 'Radio' and another that represents types of modulation (AM, FM, USB etc.) called 'Modulation'. I have defined a to-many relationship form 'Radio' to 'Modulation'. The 'Modulation' table is fixed in that I have defined the set of records in the table and I don't want the normal user to modify this.

What I do want is the user to be able to manipulate the 'Radio' records, and in particular be able to select a 'Radio' record. I have set up NSArrayControllers for both entities and they are used by two NSTableViews. So far everything is working nicely.

I want the user to be able to select a 'Radio' in the table and have the 'Modulation' table show the 'to-many' relationship by selecting the (multiple) entries that apply. Also I want the user to be able to select and deselect 'Modulation' records and have them reflected in the core data relationship.

I have tried several things involving the 'Selected Indexes' bindings on both the 'Modulation' table and the NSArrayController (pointing back to the 'Radio' controllers 'selected' entry with the key path being the to-many relationship name but this seems to either throw lots of 'not key-value coding compliant' messages or stops the 'Modulation' from displaying anything. Obviously I'm not doing this right!!!!

Can some kind soul please tell me how this can be done?

Thanks

Susan