I have some code that works perfectly fine in iOS 5, but breaks in iOS 6.
It is the TimeIntervalSinceDate method…
I’ve found others with this problem, but no solutions:
Here is my code:
NSString *origDate = @"2012-11-29 19:43:30";
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setFormatterBehavior:NSDateFormatterBehavior10_4];
[df setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSDate *convertedDate = [df dateFromString:origDate];
[df release];
NSDate* sourceDate = [NSDate date];
NSLog(@"sourceDate: %@", sourceDate);
NSLog(@"convertedDate: %@", convertedDate);
NSTimeInterval ti = [ sourceDate timeIntervalSinceDate:convertedDate];
NSLog(@"interval double: %f", ti);
In iOS 5, I get this as a value:
interval double: 711.113610
in iOS 6 I get:
interval double: 31623151.242078
Any suggestions?
Thank you
See what Apple say about Date Formatters: