I'm looking for a similar method to: NSOutlineView
parentForItem:
for NSTreeController.
I need to know the parent of a node in the tree.
Nodes in an NSTreeController
are instances of NSTreeNode
, and NSTreeNode
has a read-only parentNode
property - so use that.
The short snippet below gets the parent node of the first node in the tree-controller's selectedNodes
array:
let selectedNode = tree.selectedNodes.first! as! NSTreeNode
let parentOfSelectedNode = selectedNode.parentNode!