• 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: NSDictionaryController with NSTableView and sorting of numeric data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDictionaryController with NSTableView and sorting of numeric data


  • Subject: Re: NSDictionaryController with NSTableView and sorting of numeric data
  • From: "Shawn Erickson" <email@hidden>
  • Date: Thu, 15 May 2008 23:05:18 -0700

On Thu, May 15, 2008 at 10:43 PM, Kyle Sluder
<email@hidden> wrote:
> On Thu, May 15, 2008 at 5:30 PM,  <email@hidden> wrote:
>> It would seem that NSDictionaryController keys have to be strings.
>
> Yes.  It is very common that, despite NSDictionary accepting any
> object as a key, you must use NSString keys.
>
>> So the sorting of numeric string keys is always going to be alphabetic.
>
> Not true.  See -[NSString compare:options:] with the NSNumericSearch option.
>
>> My solution was to discard NSDictionaryController and create a proxy object
>> containing two properties:
>
> I would instead suggest subclassing NSDictionaryController and
> overriding -arrangedObjects.  The naive implementation would call
> super's implementation and return a sorted version of the result.  The
> published interface says that -arrangedObjects returns id, but the
> documentation says that it returns an array, so I would feel
> reasonably safe treating the return value as an NSArray.

Consider using the built in sort facility...

<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html#//apple_ref/occ/instm/NSArrayController/setSortDescriptors:>

<http://developer.apple.com/documentation/Cocoa/Conceptual/SortDescriptors/Concepts/Creating.html>

-Shawn
_______________________________________________

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: NSDictionaryController with NSTableView and sorting of numeric data
      • From: "email@hidden" <email@hidden>
References: 
 >NSDictionaryController with NSTableView and sorting of numeric data (From: "email@hidden" <email@hidden>)
 >Re: NSDictionaryController with NSTableView and sorting of numeric data (From: email@hidden)
 >Re: NSDictionaryController with NSTableView and sorting of numeric data (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: [MODERATOR] Re: WWDC ticket needed
  • Next by Date: Re: [MODERATOR] Re: WWDC ticket needed
  • Previous by thread: Re: NSDictionaryController with NSTableView and sorting of numeric data
  • Next by thread: Re: NSDictionaryController with NSTableView and sorting of numeric data
  • Index(es):
    • Date
    • Thread