Programmatically binding Core Data to dynamic NSTableColumns
Programmatically binding Core Data to dynamic NSTableColumns
- Subject: Programmatically binding Core Data to dynamic NSTableColumns
- From: Michael LaMorte <email@hidden>
- Date: Wed, 17 Mar 2010 13:59:09 -0400
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/method loops through the Items and creates a new Entry for each... 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 dev documentation and Googled like mad, but after 3 unproductive days I'm hoping someone here can help.
---
Michael A. LaMorte
Minder Softworks
a division of Springboard Enterprises Ltd
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden