Multiple Argument section example


#1

Maybe I am missing something but when I put in;
NSCalendar * cal = [NSCalendar currentCalendar];
NSInteger day = [cal ordinalityOfUnit:NSCalendarCalendarUnit inUnit:NSMonthCalendarUnit forDate: now];
NSLog(@“The day is %lu of the month”, day);

I get the following output which does not much look like the day;
2012-07-15 10:35:30.619 TimeAfterTime2[1920:403] The day is 9223372036854775807 of the month

Is this the correct output and if so, would you enlighten a “foggy brain”.

Thank you.


#2

Because you have “NSCalendarCalendarUnit”, whereas it should be “NSDayCalendarUnit”

Nick
http://myfirstiphoneapp.co.uk
http://easyintervalsapp.co.uk


#3

Much appreciated.


#4

Why do I have to alloc and init now, but I don’t have to do the same to later? The example below is from the book; however, I don’t understand why I don’t need to do this - NSDate *later = [NSDate alloc] init];

Example:

NSDate *now = [[NSDate alloc] init];
double seconds = [now timeIntervalSince1970];

NSDate *later = [now dateByAddingTimeInterval:100000];

#5

Some related discussions:
viewtopic.php?f=144&t=3299#p6775
viewtopic.php?f=145&t=3120
viewtopic.php?f=145&t=3882
viewtopic.php?f=145&t=3776