RE: Chronological sort descriptor?
RE: Chronological sort descriptor?
- Subject: RE: Chronological sort descriptor?
- From: "Jonathan E. Jackel" <email@hidden>
- Date: Mon, 19 Jan 2004 14:52:57 -0500
Strings don't know anything about chronology. Could you put NSCalendarDates
in your array?
for(x = 1; x < 13; x++)
{
NSCalendarData *aDate = [NSCalendarDate dateWithYear:2004
month:x day:10 hour:0 minute:0 second:0 timeZone:nil] ;
[aDate setCalendarFormat:@"%B"]
[dateArray addObject:aDate];
}
This should (NOT TESTED) generate an array of calendar dates in chron order
that, when displayed, will show only the full month name. That is,
[[dataArray objectAtIndex:0] description] yields @"January". With an
unsorted array of calendar dates, you can use [dateArray
sortedArrayUsingSelector:@selector(compare:)] to get a sorted version. (If
you wanted the months sorted alphabetically, you could make a sort
descriptor on the "description" key.)
Jonathan
>
-----Original Message-----
>
From: email@hidden
>
[mailto:email@hidden]On Behalf Of Jeremy Dronfield
>
Sent: Monday, January 19, 2004 1:52 PM
>
To: email@hidden
>
Subject: Chronological sort descriptor?
>
>
>
Possibly a dopey question, but is there a ready-made way of creating a
>
chronological sort descriptor? I have an NSMutableArray filled with the
>
names of months and want to sort them chronologically. The only
>
documentation I can find on sort descriptors deals with alphabetical or
>
numerical sorts.
>
>
-Jeremy
>
>
========================================
>
email@hidden
>
>
theLocustFarm.net:
>
- fractious fiction at http://freespace.virgin.net/jeremy.dronfield
>
========================================
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.