I receive a date through a string parameter, which is tempDateString, in a [day month year] format (for ex. 01 05 2005):
NSLog(@\"tempdatestring %@\", tempD
When you use the %@ format specifier, the return value of the -description method invoked on the provided object is used.
NSDate's -description method outputs its value in that specific way.
Your real problem though is that your date format string is incorrect - it should be dd MM yyyy.
I stuck this in a sample Xcode project:
NSString *s = @"04 11 2012";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"dd MM yyyy"];
NSDate *d = [df dateFromString:s];
NSDateComponents *c = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:d];
NSLog(@"%@", c);
It gave me the following output:
2012-10-04 01:53:24.320 dftest[59564:303]
Calendar Year: 2012
Month: 11
Leap month: no
Day: 4