I want my Mac App to do something when a row in my table view is selected. In iOS, I could use didSelectRowAt
to do something when a table view cell was tapped:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
//Some code
}
In iOS, when a table view cell was tapped, didSelectRowAt
would be executed. How do you do something like this with NSTableView in macOS?
There are two options:
tableViewSelectionDidChange(_:)
of NSTableViewDelegate
and check selectedRow
or selectedRowIndexes
selectionIndexes
of the table view to a dynamic
var of type IndexSet
and use the didSet
observer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.