Swift 使用NSN按钮选择大纲视图行
我正在为osx使用swift 4。 我有自定义单元格的nsoutlineview。 每个单元格中都有一个按钮 在my outlineView控制器类中,是此按钮的iAction操作: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)) } 但我也想选择这个按钮的行。 我
@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)