descriptionWithCalendarFormat and the iPhone?

Discussion in 'iOS Programming' started by JoshAK, Aug 12, 2008.

  1. JoshAK macrumors newbie

    Joined:
    Aug 12, 2008
    #1
    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:mad:"%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
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    Checkout NSCalendar and its components:fromDate: method.
     
  3. JoshAK thread starter macrumors newbie

    Joined:
    Aug 12, 2008
    #3
    More Help Please

    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
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    Code:
    NSCalendar *cal = [NSCalendar currentCalendar];
    NSDateComponents *comps = [cal components:kCFCalendarUnitMonth|kCFCalendarUnitDay
            fromDate:[NSDate date]];
    NSLog(@"day: %d; month: %d", [comps day], [comps month]);
     
  5. JoshAK thread starter macrumors newbie

    Joined:
    Aug 12, 2008
    #5
    Thank You!!!

    Thank you so much. I've been reading and reading trying to find the answer to that question. You've been a great help!!!:)
     
  6. andy.iphone macrumors newbie

    Joined:
    Sep 2, 2008
    #6
    Calender view

    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.
     

Share This Page