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.
I tried this to select all.
on selectAllButton_(sender)
tell theArrayController’s arrangedObjects() to setValue_ForKey_(true, “isSelected”)
end selectAllButton_
Which does nothing and I get this error in the console
08/11/2010 12:39:10 iBabel[1017] -[_NSControllerArrayProxy setValue:ForKey:]: unrecognized selector sent to instance 0x200ba86e0
08/11/2010 12:39:10 iBabel[1017] *** -[Viewer selectAllButton:]: -[_NSControllerArrayProxy setValue:ForKey:]: unrecognized selector sent to instance 0x200ba86e0 (error -10000)
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
the problem is, NSDictionary is immutable and doesn’t respond to setValue.
I recommend to use a custom class which contains the keys as properties.
Properties are automatically key-value coding compliant.
Then you can use a method like makeObjectsPerformSelector:
Many thanks for this, it is very much appreciated.
I must admit this is getting more complicated than I was expecting
Any chance you could expand a little on how the custom class would work?
Or point me in the direction of an example? I’ve searched extensively and not found an example of this type of updating of an array, perhaps I now know why.