Home > Software engineering >  Expand item in NSOutlineView with NSTreeController
Expand item in NSOutlineView with NSTreeController

Time:09-26

I'm trying (unsuccessfully) to get the node from a disclosure button clicked

I think this function is the more appropriate:

func outlineViewItemDidExpand(_ notification: Notification) {
     
     let nodeToExpand = notification.userInfo as! Node
     let nodeToExpand2 = notification.userInfo["NSObject"] as! Node

    //Error @selector(_outlineControlClicked:) from sender NSButton 0x10053d710

}

enter image description here

CodePudding user response:

NSTreeController wraps your nodes in NSTreeNode objects. Your node is representedObject of the NSTreeNode.

if let treeNode = notification.userInfo["NSObject"] as? NSTreeNode,
   let node = treeNode.representedObject as? Node {
    
}
  • Related