views:

22

answers:

0

I have a Core Data application with two entities: Item and Entries. Item has a dataType string variable. Item has a to-many inverse relationship to Entries. Entries has two variables: stringData and numberData.

I'm programmatically creating an NSTableColumn for each Item. The cell type of the column is defined by the Item's dataType variable. This part is working.

The goal is for each Item to have a column, and when clicking an Add New Entry button, a new Entry is created for each Item. The interface would add one row, with the value bound to the corresponding stringData or numberData for the Entry for that Item.

Right now, the Add New Entry button loops through the Items and creates a new Entry, that's working okay. Where I'm having problems is figuring out the bindings to properly display the columns. The bind statement I'm using is:

[itemColumn bind:@"value" toObject:entryArrayController withKeyPath:@"arrangedObjects.numberData" options:nil];

(It's in an if statement, so it binds to either numberData or stringData as appropriate.)

This results in 1 row being added for each Item, and the entire row is bound to the same value. So if I have 6 Items, I correctly have 6 columns (one for each Item) but clicking Add New Entry it incorrectly generates 6 rows, one for each Item.

I've tried many variations of the toObject and withKeyPath: values to no avail. I've looked through all the Key Value Coding and other Apple documentation and Googled like mad, but after 3 unproductive days I'm hoping someone here can help.