Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找一种类似的方法:NSOutlineView parentForItem:对于 NSTreeController。
NSOutlineView
parentForItem:
我需要知道树中节点的父节点。
an 中的节点是 , 的NSTreeController实例NSTreeNode,并且NSTreeNode具有只读 parentNode属性 - 所以使用它。
NSTreeController
NSTreeNode
parentNode
selectedNodes下面的简短片段获取树控制器数组中第一个节点的父节点:
selectedNodes
let selectedNode = tree.selectedNodes.first! as! NSTreeNode let parentOfSelectedNode = selectedNode.parentNode!