Select rows in a table based on row numbers

All,
I have an app where user can store a car name and its features. The car names are shown in a combobox and the features are represented as a single column table view. A user can select multiple features(rows). When user hits the save button, I store the car name and selected row numbers( For e.g. “1,2,7”) as a string in a plist file. I load the stored data in form fields when user selects an existing car. I’m having trouble selecting the feature rows.
I have hooked an array controller to the features column (From Shane Stanley’s AppleScriptObjC Explored Table example)

Here is the code that I have so far:

property aFeaturetable: missing value
property theData : {} -- the table data
property theArrayController : missing value -- connected in Interface Builder
property aFeatureList: {"","GPS", "Cruise Control", "Sunroof", "Entertainment System"}

on fillFormData()
 --Fetch data from plist file for the selected car name 
 set theVal to thePlistData's valueForKey_(selectedcarName)
 set rowStr to (theVal's valueForKey_("theFeatures")) as string --  "1,2,3" 
 my selectRowFeatures(rowStr)
end fillFormData

on selectRowFeatures(val)
set {myTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, {","}}
        set selRowsList to text items of val 
        set AppleScript's text item delimiters to myTID 
        repeat with i in selRowsList
            tell theArrayController to setSelectionIndex_(i as integer)
        end repeat
end selectRowFeatures


How do I select the table rows based on the row numbers ? I read about a method called selectRowIndexes:byExtendingSelection: in the Xcode Docs, but couldn’t make it work. The setSelectionIndex method didn’t work for me as it selects only one row. I wish for a multiple select pop-up control

Try something like this:

set selRowsList to text items of val 
set theSet to current application's NSMutableIndexSet's alloc()'s init()
repeat with anIndex in selRowsList
theSet's addIndex_(anIndex)
end repeat
tell theArrayController to selectRowIndexes_byExtendingSelection_(theSet, false)

Thanks shane.

tell theArrayController to selectRowIndexes_byExtendingSelection_(theSet, false)

didn’t work for me. But it set me on the right path.

aFeaturetables's selectRowIndexes_byExtendingSelection_(theSet, false)

worked as selectRowIndexes_byExtendingSelection_ is a NSTableView method.

Right – comes from typing into a browser…