my NSDateFormatter works only in the iPhone simulator

Posted by Manuel Spuhler on Stack Overflow See other posts from Stack Overflow or by Manuel Spuhler
Published on 2009-05-08T08:56:03Z Indexed on 2010/04/16 14:23 UTC
Read the original article Hit count: 288

Filed under:
|
|
|

I use a NSDateFormatter which works fine in the simulator, but I get a nil when I run it in the iPhone. I hardcoded the date to be sure of the format, but it fails anyway.

NSString *strPubDate = @"Fri, 8 May 2009 08:08:35 GMT";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[dateFormatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss Z"];

NSDate *myDate = [dateFormatter dateFromString:strPubDate];

I tried with different region settings, languages etc. on the iPhone. Any idea what is going wrong?

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about iphone