Steven Schafer Steven Schafer - 1 month ago 7
Objective-C Question

How do I NSLog an NSDate?

With the code pasted below, I am trying to log an NSDate. What am I doing wrong here?

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"YYYY-MM-dd"];
NSDate *todaysDate;
todaysDate = [NSDate date];
NSLog(@"Todays date is %@",formatter);


All you have to do is:

  NSLog(@"Todays date is %@",[formatter stringFromDate:todaysDate]);