selecting table row

I wanted to select a row in a table typing its index in a text field, so I binded the text field to a property and the selection indexes of the array controller to another one.
Ok, in the end I figured it out how to do that, and now the app works perfectly.
The reason why I’m opening this thread is that I don’t understand very well what’s really happening in the code I wrote (I do know: it seems unbelievable…) and I’d like to know more about it.
So my code is this:

on tableSelect(prm)
	set tmp to my selIdx
	tmp's removeAllIndexes()
	tmp's addIndex_(prm)
	set my fileList to my fileList
	set my selIdx to tmp
end tableSelect

where prm is a given number, selIdx is the selection indexes property and fileList is the array controller property. It looks like that’s the only way selecting a table row from within the code. I tried lots of different combinations but none of them worked. So in particular I’m wondering why It’s necessary to “reload” the array controller property (that is setting it again with itself) before setting selIdx to its new value…

Just curious, nothing more. :slight_smile:

Thank you

This is (obviously) not the answer to my question, but, if anyone is interested in it, the proper way for selecting a table row is this

property theIndexSet : class "NSIndexSet"

on tableSelect_(prm)
	set idxs to my theIndexSet's indexSetWithIndex_(prm)
	my theTable's selectRowIndexes_byExtendingSelection_(idxs, false) 
end tableSelect_

where “false” can be “true” if you want to extend your current selection instead of replacing it.