How to get selected item of NSOutlineView without using NSTreeController?

Ronaldo Nascimento picture Ronaldo Nascimento · Feb 12, 2010 · Viewed 11.9k times · Source

How do I get the selected item of an NSOutlineView with using my own data source. I see I can get selectedRow but it returns a row ID relative to the state of the outline. The only way to do it is to track the expanded collapsed state of the items, but that seems ridiculous.

I was hoping for something like:

array = [outlineViewOutlet selectedItems];

I looked at the other similar questions, they dont seem to answer the question.

Answer

Dave DeLong picture Dave DeLong · Feb 12, 2010

NSOutlineView inherits from NSTableView, so you get nice methods such as selectedRow:

id selectedItem = [outlineView itemAtRow:[outlineView selectedRow]];