I have a code that was working until iOS 4.3.5, now in iOS 5 it’s not working:
//Example of date I'm using: Mon, 31 Oct 2011 15:57:55 BRST
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"EEE, d MMM yyyy HH:mm:ss vvvv"];
[formatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"] autorelease]];
NSString *dateString = [TBXML textForElement:[TBXML childElementNamed:@"pubDate" parentElement:XML]];
NSDate *data = [formatter dateFromString:dateString];
[formatter release];
Now, data is coming (null). Does anybody know what I did wrong?
Regards!
EDIT:
I was looking in the file NSDateFormatter.h and I found:
// - (id)init; // designated initializer
init is commented, so I am not allowed to use [[NSDateFormatter alloc] init] right? Is there any other way to create ah instance of NSDateFormatter ?
You can init the NSDateFormatter with initWithDateFormat:allowNaturalLanguage:
NSDateFormat Class Reference
SO-Question
NSDateFormatter's init method is deprecated?
Hope that helps?