Selecting A Row In An NSTableView Programmatically
Joshua, make sure to use the developers documentation to determine whether or not it's a delegate method. If it were a delegate method, it would be mentioned in the docs for NSTableViewDelegate.
What you’re looking for is very straight forward.
Objective-C
NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:1];
[tableview selectRowIndexes:indexSet byExtendingSelection:NO];
Swift 2
let indexSet = NSIndexSet(index: 1)
tableView.selectRowIndexes(indexSet, byExtendingSelection: false)
Again. Make sure to look up the method selectRowIndexes:byExtendingSelection in the docs to see what parameters it needs. It says an NSIndexSet is needed. Then look up NSIndexSet and you'll discover how to use that.
Joshua
Objective-C and Swift programmer with almost 10 years experience. Began developing on Mac and now focussing on iOS. Current app focus is in the area of development tools and rich text editing. Interested in compiler and interpreter design. Dabbles with PHP, HTML/CSS, Javascript and Python. Fan of Star Trek & Twin Peaks.
Updated on April 11, 2020Comments
-
Joshua about 4 years
I want to Select A Row in my table view programmatically, I believe I would use
selectRowIndexes:byExtendingSelection:
(is this a delegate method?). The other thing is how would I use that method to select the second row (in programming terms row 1)?