Re: Table sort image question
Re: Table sort image question
- Subject: Re: Table sort image question
- From: Graham Cox <email@hidden>
- Date: Wed, 7 Jan 2009 00:38:37 +1100
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
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.
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).
hth,
Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden