Re: Custom compare: for NSDate sort descriptor
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