Re: programmatically sorting an NSTableView
Re: programmatically sorting an NSTableView
- Subject: Re: programmatically sorting an NSTableView
- From: Ken Thomases <email@hidden>
- Date: Tue, 12 Jul 2011 16:04:32 -0500
On Jul 12, 2011, at 3:43 PM, James Walker wrote:
> I have an NSTableView containing one column, which is bound to an NSArrayController. I've set a sort key and selector for the column in IB, and I've called setSortDescriptors: on the array controller. Clicking the column header sorts it, but how can I sort programmatically? It seems odd that I look through the methods of NSTableView, NSTableColumn, and NSArrayController, and there are methods for setting sort descriptors but nothing that says "sort it". I suppose that -[NSTableView setAutomaticallyRearrangesObjects:] might help, but it requires 10.5 and I need to support 10.4. Help?
Invoking -setSortDescriptors: on the array controller does sort it (or should). Back on 10.4, it may have been necessary to follow that with a call to -rearrangeObjects.
(And -setAutomaticallyRearrangesObjects: is a method on NSArrayController, not NSTableView. And I don't think it should be necessary to get the array controller to rearrange its objects due to an explicit request like -setSortDescriptors: -- it already knows how to do that. It's a way to make the array controller track the properties of the objects in the array which are referenced by the sort descriptors and filtering predicate so that it re-sorts or re-filters when those values change.)
Regards,
Ken
_______________________________________________
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