Xcode Swift. How to programmatically select Cell in view-based NSTableView

做~自己de王妃 提交于 2019-12-04 14:57:49

I'd googled this for two days solid before asking the question here. But now almost immediately after posting the question I managed to get it working. In fact it's so simple I can't believe it took so long to figure it out.

// Assuming we want to programmatically select Column 4, Row 5
myTableView?.editColumn(4, row: 5, withEvent: nil, select: true)

On my travels I found dozens of people asking this question but no simple answers. Or answers that actually worked with NSTableView rather than UITableView and when tableView is 'view based' rather than cell based. So I hope me posting this here will help some of those people.

Use can use this , if you just want to highlight the table view cell or row and also performs some operations to it through tableViewSelectionDidChange delegate method of the NSTablView.

mytableView.selectRowIndexes(IndexSet([indexOfTheCellWantToSelect]), byExtendingSelection: true)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!