I put this on the ASS Xcode forum but I now realise that my problems may be better addressed here.
I have a four column table in which the third column contains a checkbox.
The data comes a UNIX app and I use a repeat loop to get the data for each molecule in the file and add it to new_TableData
set record_detail to {names:num_uni_rec, tlable:new_name, isSelected:false, fileName:input_file}
copy record_detail to the end of new_TableData
and then
tell theArrayController
removeObjects_(arrangedObjects())
addObjects_(new_TableData)
end tell
to add the data, it then displays in the table.
To get data to set up a webview displaying a structure I used:
set theSel to theArrayController's selectedObjects() as list
--log theSel
--returns {{fileName = "/Users/swain/Desktop/the_hits.smiles";isSelected = 1;names = 12;tlable = Molecule12;}}
I now need to be able to select all, select none and invert selection.
With StefanK’s much appreciated help I’ve got to this stage
set theTableItems to theArrayController’s arrangedObjects()
–log theTableItems
repeat with n from 1 to count of theTableItems
set theTableItemsObject to theTableItems’s objectAtIndex_(n - 1)
log theTableItemsObject
theTableItemsObject’s setValue_ForKey_(1, “isSelected”)
end repeat
But I get this error
12/11/2010 11:12:00 iBabel[9734] *** -[Viewer selectAllButton:]: -[NSCFDictionary setValue:ForKey:]: unrecognized selector sent to instance 0x2008155c0 (error -10000)
Apparently the problem is, NSDictionary is immutable and doesn’t respond to setValue, and the suggestion is to use a custom class.
This is rather more than complicated than I had imagined, any suggestions welcome:)