On 19/07/2010, at 4:10 AM, Gideon King wrote:

> I guess if there isn't already something built in, I may have to either 
> subclass something in the table header and make it three state, or maybe 
> override somewhere in the tableview or array controller where it sets the 
> sort descriptors or perhaps turn off the automatically hidden scrollers and 
> put a button in the cornerView... any suggestions or examples would be 
> appreciated.

There's not really any such thing as an "unsorted" order.

If the order that you added items to your data set is important, and you want 
to sort on that, you probably should define a property which is the ordinal of 
the item as originally created, or timestamp them so you can sort on creation 
time, etc. Then you have a property on which you can sort to recover that order 
at any time. You can then add a sort descriptor for it which could either be 
added to the tableview's sort descriptors - I believe if you add one that 
doesn't correspond to a column it will still hold onto it for you but it will 
gradually get pushed to the back of the list as the table is used, but as I 
found the other week it's probably better to move the sort descriptor handling 
to your controller (tableview's datasource/delegate) and take that 
responsibility away from the tableview.

Once you have the sort descriptor handling in the controller, you can easily 
implement a three-state sorting if you want - the table view merely informs you 
that the sort order has changed, so you can cycle through different sort 
descriptors as you wish, and then update the table column headers to match. 
Easier might be just to have a table column for the original ordinal order so 
the user can see what they are sorting on instead of working out that there's a 
third "unsorted" state. iTunes does that for example.

--Graham


_______________________________________________

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

Reply via email to