views:

182

answers:

1

I am looking to retrieve the selected object in an NSOutlineView so I can see if the selected object has any children. How would I do this?

+4  A: 

NSOutlineView inherits the -selectedRow method from NSTableView. I suspect though, that what you really want is the current selection from whatever NSController is acting as your outline view's data source.

NSResponder
The NSTreeController? How would I retrieve that then?
Joshua
If the NSTreeController is defined in your .xib/.nib file, you can create and link up an IBOutlet field in your controller to point to it and access it that way.
Quinn Taylor
Go to the documentation for NSTreeController, and see the section labeled "Getting the Current Selection".
NSResponder
Ah, I see. So I can use Selected objects like `[treeController selectedObjects]`? But how would I then find the amount of children it has?
Joshua
You need to read through the NSTreeController docs. How you determine whether a given node is a leaf or has children depends on the model.
NSResponder
This is what I got. http://snapplr.com/zsm6
Joshua