How to disable sorting in NSTableVIew?

青春壹個敷衍的年華 提交于 2019-12-03 12:54:01

Sorting of the NSTableView is done by its sortDescriptors, see here.

An NSTableColumn uses its sortDescriptorPrototype (see here) to generate the sort descriptor of the NSTableView, depending on how many times you clicked the column header, etc.

If you use dataSource to manage the data, then the sort descriptor is communicated via the delegate method tableView:sortDescriptorsDidChange:, see here. You just need to ignore the change message to stop sorting.

If you use Cocoa bindings to manage the data, the sort descriptor is generated by the table column and set to the NSArrayController. To stop it, just open the inspector of the binding of the table column, select value, and uncheck "Creates Sort Descriptor."

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