Q:

NSDateFormatter returning nil NSDate object

NSDateFormatter *aDateFormatter = [[NSDateFormatter alloc] init];
[aDateFormatter setLocale:aLocale];
[aDateFormatter setDateStyle:NSDateFormatterFullStyle];
[aDateFormatter setDateFormat:@"EEE, MMM dd, yyyy"];
NSDate *aDateFromString = [aDateFormatter dateFromString:aKey];

Here,
aKey = lun, October 11, 2010
aLocale = fr_CH
My aDateFromString is coming as nil. What is wrong with my code?

A:

Playing around with this for a bit, and this code below gets a legit NSDate:
NSString *df = @"EEE, MMM dd, yyyy";
NSString *ds = @"lun., Octobre 11, 2010";
NSLocale *aLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"fr_CH"];

NSDateFormatter *aDateFormatter = [[NSDateFormatter alloc] init];
[aDateFormatter setLocale:aLocale];
[aDateFormatter setDateStyle:NSDateFormatterFullStyle];
[aDateFormatter setDateFormat:df];
NSDate *aDateFromString = [aDateFormatter dateFromString:ds];

