Multiple Argument section example


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.


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



Much appreciated.


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];


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

NSDate *later = [now dateByAddingTimeInterval:100000];


Some related discussions: