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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)