• 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: Chronological sort descriptor?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Chronological sort descriptor?
      • From: Jeremy Dronfield <email@hidden>
References: 
 >Chronological sort descriptor? (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Re: Search field crashing
  • Next by Date: NSError and Jaguar
  • Previous by thread: Chronological sort descriptor?
  • Next by thread: Re: Chronological sort descriptor?
  • Index(es):
    • Date
    • Thread