I'm using NSOutlineView
without NSTreeController
and have implemented my own datasource. What is the best way to select an item?
NSOutlineView
support already expandItem:
and collapseItem:
. And I'm missing a handy method like `selectItem:. How can I do it programatically ?
Thank you.
Remember to look in superclasses when you can't find something. In this case, one of the methods you need comes from NSTableView, which is NSOutlineView's immediate superclass.
The solution is to get the row index for the item using rowForItem:
, and if it isn't -1 (item not visible/not found), create an index set with it with [NSIndexSet indexSetWithIndex:]
and pass that index set to the selectRowIndexes:byExtendingSelection:
method.