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
2009-09-15 16:44:48
The NSTreeController? How would I retrieve that then?
Joshua
2009-09-15 16:49:04
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
2009-09-15 17:19:33
Go to the documentation for NSTreeController, and see the section labeled "Getting the Current Selection".
NSResponder
2009-09-15 17:26:56
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
2009-09-16 05:46:35
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
2009-09-16 22:48:54
This is what I got. http://snapplr.com/zsm6
Joshua
2009-09-18 17:34:39