使用 NSTreeController 展开 NSOutlineView 中的项目
Expand item in NSOutlineView with NSTreeController
我正在尝试(未成功)从单击的披露按钮获取节点
我觉得这个功能比较合适:
func outlineViewItemDidExpand(_ notification: Notification) {
let nodeToExpand = notification.userInfo as! Node
let nodeToExpand2 = notification.userInfo["NSObject"] as! Node
//Error @selector(_outlineControlClicked:) from sender NSButton 0x10053d710
}
NSTreeController
将您的节点包装在 NSTreeNode
个对象中。您的节点是 NSTreeNode
的 representedObject
。
if let treeNode = notification.userInfo["NSObject"] as? NSTreeNode,
let node = treeNode.representedObject as? Node {
…
}
我正在尝试(未成功)从单击的披露按钮获取节点
我觉得这个功能比较合适:
func outlineViewItemDidExpand(_ notification: Notification) {
let nodeToExpand = notification.userInfo as! Node
let nodeToExpand2 = notification.userInfo["NSObject"] as! Node
//Error @selector(_outlineControlClicked:) from sender NSButton 0x10053d710
}
NSTreeController
将您的节点包装在 NSTreeNode
个对象中。您的节点是 NSTreeNode
的 representedObject
。
if let treeNode = notification.userInfo["NSObject"] as? NSTreeNode,
let node = treeNode.representedObject as? Node {
…
}