NSArray to AS List

I put a single column table in my application and am trying to make the data editable. It looks like I have a problem converting between a list and NSArray, but I can’t figure out what to do… The table loads data just fine, but I get a crash whenever I edit (double-click to edit) any text in the table. I haven’t even added a button to ‘save’ the table data yet…

Any thoughts?
Y

Code: (or parts of it…)
property teamList : {} --list of teams
property theArrayController : missing value

    tell defaults to registerDefaults_({rsyncAutoStartKey:false,yedPKey:"secret",teamListKey:{"Music","Science","Admin"}})
    tell defaults to set my yedP to objectForKey_("yedPKey")
    tell defaults to set teamListAS to objectForKey_("teamListKey")
    tell current application's NSArray to set my teamList to arrayWithArray_(teamListAS)

Crash Report:

2013-07-22 14:08:07.606 Yed-Server[36707:303] Exception detected while handling key input.
2013-07-22 14:08:07.607 Yed-Server[36707:303] Error setting value for key path self of object Science (from bound object <NSTableColumn: 0x101a25c20> identifier: (null)): [<__NSCFString 0x1005a03a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key self.

Hi,

The AppleScript / Cocoa conversion is not the problem.
It looks like you bound the value of the table column to the arrayController > arrangedObjects > self.
This is fine for a read only table, but isn’t sufficient for editing the entries.

To change any value in the table the array controller expects a NSMutableDictionary (record) with a specific key for the data source, because it calls the method setValue:forKey:
Bind the model key path to name instead of self and use a record


set my teamList to {{|name|:"Music"}, {|name|:"Science"}, {|name|:"Admin"}}

But for a single column it’s much easier to use the datasource delegate methods rather than an array controller.

Thank you! Your message was very helpful and I have it working now. I was using self as I was using the tutorial on tables in The Book and hadn’t changed it.

Where can I get info on this datasource delegate method? Is that in Shane’s book also? I don’t remember seeing it…
-t-

Take a look at NSTableViewDataSource Protocol Reference