是的,我刚刚注意到这个问题。显然,Apple 报告了此错误,请参阅http://openradar.appspot.com/12358210
编辑:这就是我在我正在处理的项目中处理这个问题的方式......
// I use the following code in a category to parsing date strings
- (NSDate *)dateWithPath:(NSString *)path format:(NSString *)format
{
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
formatter.dateFormat = format;
NSString *string = [self valueWithPath:path];
return [formatter dateFromString:string];
}
// old parsing code that worked fine in iOS 5, but has issues in iOS 6
NSDate *date = [element dateWithPath:@"datum_US" format:@"yyyy-MM-dd"];
NSDate *timeStart = [element dateWithPath:@"aanvang" format:@"HH:mm:ss"];
NSTimeInterval interval = [timeStart timeIntervalSince1970];
match.timeStart = [date dateByAddingTimeInterval:interval];
和修复...
// the following code works fine in both iOS 5 and iOS 6
NSDate *date = [element dateWithPath:@"datum_US" format:@"yyyy-MM-dd"];
NSDate *timeStart = [element dateWithPath:@"aanvang" format:@"HH:mm:ss"];
NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
calendar.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
NSUInteger units = NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit;
NSDateComponents *timeComps = [calendar components:units fromDate:timeStart];
match.timeStart = [calendar dateByAddingComponents:timeComps toDate:date options:0];