I recently upgraded to iOS 6 and have noticed dateFromString is not working correctly, unless I'm doing something wrong with my dateFormat. It was working prior to the upgrade.
Code:
NSString *string = @"2012-09-24 - Sun";
NSLog(@"string = %@", string);
NSDateFormatter *df = [[NSDateFormatter alloc] init];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
[df setLocale:locale];
[df setDateFormat:@"yyyy-MM-dd - EEE"];
NSDate *date = [df dateFromString:string];
NSLog(@"date = %@", date);
Output:
string = 2012-09-24 - Sun
date = 1999-12-26 05:00:00 +0000
Any suggestions?
Looks like the formatters changed specs in iOS 6:
Please check this: