• 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: Ken Thomases <email@hidden>
  • Date: Wed, 13 Jul 2011 01:43:08 -0500

On Jul 12, 2011, at 9:24 PM, James Walker wrote:

> On 7/12/2011 6:14 PM, Ken Thomases wrote:
>> On Jul 12, 2011, at 5:36 PM, James Walker wrote:
>>
>>> 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.
>>
>> Is your array controller bound to its content, or are you setting that programmatically?  If it's bound, then it ought to rearrange its objects when they are added.  The fact that it doesn't suggests that you aren't updating the property to which it is bound in a KVO-compliant manner.
>
> The table column is bound to the array controller using IB.

OK, but I was trying to get at the question of from where the array controller gets its content.  Is its contentArray binding bound?  Or are you setting its content programmatically using -initWithContent: or -setContent:?

> I was adding new items using -[NSArrayController addObject:].  What's the better way?

That's fine and should work.  I don't know why the array controller isn't re-arranging its content.  Maybe my understanding of that behavior is wrong.  When you weren't calling -rearrangeObjects, were the added objects showing up in the table at all (but maybe in the wrong order)?

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

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

  • Prev by Date: Re: iOS: Differentiating between 1 or 2 finger touches
  • Next by Date: NSMenuItem alternate view with CMD key problem
  • Previous by thread: Re: programmatically sorting an NSTableView
  • Next by thread: Re: programmatically sorting an NSTableView
  • Index(es):
    • Date
    • Thread