On 7 Jan 2009, at 12:18 am, Jon C. Munson II wrote: > 1. When is didClickTableColumn actually called? Is it after the > table does > its stuff, including setting the sort descriptors, or just prior to > that?
This is not the method you want. You want the NSTableDataSource method: - (void) tableView:(NSTableView*) aTableView sortDescriptorsDidChange: (NSArray*) oldDescriptors In this method, you can retrieve the *current* sortDescriptors from the tableview, and sort a mutable array using: - (void) sortUsingDescriptors:(NSArray*) sortDescriptors [Jon C. Munson II] Thank you for this, I'm looking into it now. Note that the sort descriptors passed in the first method are the old ones, not the current ones, so you have to go back to the table to get the new ones. Having sorted the array, you need to reload the table to display the outcome. That's all - there's nothing else you need to do to support sorting from table columns except setting up the sort key and selector in IB. [Jon C. Munson II] OK. Thank you for that. I decided to stick with the delegate method of didClickTableColumn as it functionally provides the same thing (at this time) without having to create yet another class, instantation, etc. I will keep that in mind for future use though, so I appreciate the pointer to it. > 2. In attempting to answer #1, I ran into an issue with using the > -ascending message. The doc states its returns a bool, however, I > could not > use the message. Any ideas there? I don't see any reason to actually try and access the sort descriptor itself - just use it as a black box. Note that sort descriptors come in an array, so there could be several, one for each sortable column. I can't see immediately in the docs what order they come in, so you can't necessarily tell which sort descriptor represents a particular column (though my *guess* is that the first one is the selected column header). [Jon C. Munson II] I found in subsequent testing that didClickTableColumn appears to get called after the table sets its sort descriptors, etc. So, as you pointed out, I didn't need to do anything really with the sort descriptor other than "pass it along." Now, I've got to unhook the sortKeys in my hack of covertflow and use the sort descriptor as passed. Adapt and overcome.... Thank you for your help so far. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com