Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 使用NSN按钮选择大纲视图行_Swift_Macos_Cocoa_Nsoutlineview - Fatal编程技术网

Swift 使用NSN按钮选择大纲视图行

Swift 使用NSN按钮选择大纲视图行,swift,macos,cocoa,nsoutlineview,Swift,Macos,Cocoa,Nsoutlineview,我正在为osx使用swift 4。 我有自定义单元格的nsoutlineview。 每个单元格中都有一个按钮 在my outlineView控制器类中,是此按钮的iAction操作: @IBAction func showInfo(_ sender: NSButton) { // Get the row of clicked button print(myOutlineView.row(for: sender as NSView)) } 但我也想选择这个按钮的行。 我

我正在为osx使用swift 4。 我有自定义单元格的nsoutlineview。 每个单元格中都有一个按钮

在my outlineView控制器类中,是此按钮的iAction操作:

@IBAction func showInfo(_ sender: NSButton) {     

   // Get the row of clicked button
   print(myOutlineView.row(for: sender as NSView))

}
但我也想选择这个按钮的行。 我想我必须使用这个命令:

myOutlineView.selectRowIndexes(<NSIndexSet>, byExtendingSelection: <Bool>)
myOutlineView.selectRowIndexes(,byExtendingSelection:)

但是如何获得NSIndexSet值呢?

好的,我找到了解决方案:

myOutlineView.selectRowIndexes(IndexSet(integer: myOutlineView.row(for: sender as NSView)), byExtendingSelection: false)