• 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: Custom compare: for NSDate sort descriptor
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom compare: for NSDate sort descriptor


  • Subject: Re: Custom compare: for NSDate sort descriptor
  • From: "Adam R. Maxwell" <email@hidden>
  • Date: Tue, 9 Oct 2007 08:53:29 -0700


On Oct 9, 2007, at 07:46, George Orthwein wrote:

Solved! But not with a category after all. :)

I first implemented a category but found that nil date values weren't being sent to my custom compare method at all! Quite a problem. I searched a bit and did find a thread where the poster had created a custom NSSortDescriptor subclass... he couldn't quite remember why he didn't use a custom compare method and I suspect it was because of these nil values.
http://www.cocoabuilder.com/archive/message/cocoa/2006/7/5/166885

Being the OP of that thread, I'll just mention that I did work around the performance problems and bugs inherent in subclassing NSSortDescriptor. It required implementing my own version of - [NSMutableArray sortUsingDescriptors:] (using mergesort and caching, probably similar to what Apple does) but avoids the problems with compareObject:toObject:. BSD licensed code's available at <http://bibdesk.svn.sourceforge.net/viewvc/bibdesk/trunk/bibdesk/NSArray_BDSKExtensions.m?revision=11217&view=markup >, but I'd avoid the approach if at all possible.


--
adam
_______________________________________________

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


References: 
 >Re: Custom compare: for NSDate sort descriptor (From: Keary Suska <email@hidden>)
 >Re: Custom compare: for NSDate sort descriptor (From: George Orthwein <email@hidden>)

  • Prev by Date: multicasting and distributed objects
  • Next by Date: Re: Getting Carbon Volume Mount Events in a Cocoa (Core Foundation) process
  • Previous by thread: Re: Custom compare: for NSDate sort descriptor
  • Next by thread: Re: Custom compare: for NSDate sort descriptor
  • Index(es):
    • Date
    • Thread