I am trying to convert a string which is of the format August 1, 2011 to a NSDate.
I used the following code
NSString *dateStr = @"Aug 3, 2011";
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MMMM d, YYYY"];
NSDate *date = [dateFormat dateFromString:dateStr];
[picker setDate:date animated:YES];
But the output is get is not the December 26, 2010 in the date picker.
Regarding your comment on Bertrand Marron's answer, if you are sure you have the date formatter right, perhaps the problem is with your picker? Can you check the value of the date in the debugger and confirm that is correct? Is your picker a custom subclass or the standard date picker?
EDIT:
After reproducing this myself, I have the answer.
Replace
[dateFormat setDateFormat:@"MMMM d, YYYY"];
with
[dateFormat setDateFormat:@"MMMM d, yyyy"];
Upper case YYYY indicates "Week of year" in the ISO year-week calendar. See documentation for data formatting guide --> Date formatters for example.