On May 30, 2008, at 12:48 AM, James W. Walker wrote:
Hi. I'm a Cocoa newbie, and I'm trying to figure out how to enable
sorting columns of my table, but the NSTableView guide doesn't say
anything about it. I see that NSTableView has a setSortDescriptors
method, NSTableColumn has a setSortDescriptorPrototype method, and
that IB shows a "sort key" attribute for a table column, but I'm not
clear on how to use them. Any hints or examples?
I'm sure Vijay's solution is more correct than mine, but I implement the
delegate method and highlight the column header myself (reversing the
sort as necessary and setting the right sort direction indicator).
Then I sort my data source and call reloadData on the table object.
I found this MacTech article useful for getting to know NSTableView a
little better also: