• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: programmatically sorting an NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: programmatically sorting an NSTableView


  • Subject: Re: programmatically sorting an NSTableView
  • From: James Walker <email@hidden>
  • Date: Tue, 12 Jul 2011 15:36:19 -0700

> Am 12.07.2011 um 22:43 schrieb James Walker:
>
>> 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?

On 7/12/2011 1:51 PM, Peter wrote:
See here:

http://www.cocoabuilder.com/archive/cocoa/174051-programmatically-sort-nstableview.html

I saw that before I posted my question, but I didn't think it was relevant, since it seemed to be talking about a table loaded from a data source rather than a table that uses bindings.


and here

http://www.cocoabuilder.com/archive/cocoa/115880-programatically-sorting-tableview.html

I didn't see that one before, but now I have tried calling -[NSTableView setSortDescriptors:] after adding content, and it didn't work.



On 7/12/2011 2:04 PM, Ken Thomases wrote:

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.

-[NSArrayController setSortDescriptors:] alone doesn't work for me even on 10.6, but that combined with -[NSArrayController rearrangeObjects] does the trick. That is, I set use setSortDescriptors: once, and use rearrangeObjects whenever I add new items to the table.



Thanks for the replies! -- James W. Walker, Innoventive Software LLC <http://www.frameforge3d.com/> _______________________________________________

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


  • Follow-Ups:
    • Re: programmatically sorting an NSTableView
      • From: Ken Thomases <email@hidden>
References: 
 >programmatically sorting an NSTableView (From: James Walker <email@hidden>)
 >Re: programmatically sorting an NSTableView (From: Peter <email@hidden>)

  • Prev by Date: Re: programmatically sorting an NSTableView
  • Next by Date: iOS: Differentiating between 1 or 2 finger touches
  • Previous by thread: Re: programmatically sorting an NSTableView
  • Next by thread: Re: programmatically sorting an NSTableView
  • Index(es):
    • Date
    • Thread