PDA

View Full Version : descriptionWithCalendarFormat and the iPhone?




JoshAK
Aug 12, 2008, 07:16 PM
Hi,
I'm working on an app that requires the current day and month in the
following format: 108 the number 1 representing the day of the month
and the 08 representing the month. If I were to write this in an
application that would run on a Mac I would use
descriptionWithCalendarFormat:@"%e%m" timeZone:nil locale:nil. That
works fine in the iPhone simulator, but when I load the app into the
phone it gives me warnings. Can anyone please help me use some other
date format. Thanks,
Josh



kainjow
Aug 12, 2008, 11:56 PM
Checkout NSCalendar and its components:fromDate: method.

JoshAK
Aug 13, 2008, 12:26 PM
I'm new to cocoa can you give me an example of how I would get that info using components:fromDate: method I'm still not sure how I can do this.

Thanks,

Josh

kainjow
Aug 13, 2008, 12:56 PM
NSCalendar *cal = [NSCalendar currentCalendar];
NSDateComponents *comps = [cal components:kCFCalendarUnitMonth|kCFCalendarUnitDay
fromDate:[NSDate date]];
NSLog(@"day: %d; month: %d", [comps day], [comps month]);

JoshAK
Aug 13, 2008, 01:41 PM
Thank you so much. I've been reading and reading trying to find the answer to that question. You've been a great help!!!:)

andy.iphone
Jan 1, 2009, 07:33 AM
Pls help me -----where can i got code for calender....:)
Complete code required for NSCalender.....pls help

kainjow's code helpful.But I can't implement it.

As I'm newbe.