selecting checkbox in table

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)

Iā€™ve also tried setValue_ForKey_(1, ā€œisSelectedā€)

Any help appreciated

Hi,

arrangedObjects returns a NSArray. As the objects of the array are dictionary objects
you need a repeat loop to set a single key/value

Hi,

So I tried

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

This logs

12/11/2010 11:13:08 iBabel[9769] {
fileName = ā€œ/Users/swain/Desktop/FLS000034.sdfā€;
isSelected = 0;
names = 1;
tlable = Chemistry;
}

So I tried

	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)

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 :frowning:

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.

Sorry, I donā€™t ā€œspeakā€ AppleScriptObjC, because Iā€™m still on PowerPC.

This is a very simple Cocoa example TableView_Test