Search code examples
objective-ccocoanstableviewnsoutlineview

set NSOutlineView's selection programmatically (and get NSTableView's selection)


I want to set my OutlineView's selection programmatically in another class.

I'm able to acces the instance of NSOutlineView by [[appDelegate outlineViewController] outlineView].

The idea behind this, is that I have a view with a list of items (that are also in the outlineview) and I want the user to be able to click on the item in the view, so that the outlineviews's selection is changed and thus a new view (of the selected item) appears.

So again, How can I change OutlineView's selection programmatically?

If the question looks unclear, please let me know what can I do to make it more understandable.


Solution

  • If I am understanding you correctly, I think you are looking for the NSOutlineView's – selectRowIndexes:byExtendingSelection: method. Note that NSOutlineView is a subclass of NSTableView.