0

I'm looking for a similar method to: NSOutlineView parentForItem: for NSTreeController.

I need to know the parent of a node in the tree.

stevekohls
  • 2,214
  • 23
  • 29
aneuryzm
  • 63,052
  • 100
  • 273
  • 488

1 Answers1

0

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!
Paul Patterson
  • 6,840
  • 3
  • 42
  • 56