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