在使用iOS4.0编译之前,这工作正常,我无法弄清楚什么是错的。来自XML的NSDateFormatter的NULL值
这是问题所在。我从我的数据库中发送我的应用程序分数与日期/时间。我的目标是将其存储在CoreData中。当我使用下面的代码时,我得到了日期的空值。
代码:
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"US"];
[dateFormatter setLocale:locale];
[dateFormatter setDateFormat:@"MM/dd/yyyy HH:mm:ss ZZZ"];
currentDownloadedScore.dateEntered = [dateFormatter dateFromString:self.currentValue];
NSLog(@"Date CV: %@",self.currentValue);
NSLog(@"Date: %@",[currentDownloadedScore.dateEntered description]);
[locale release];
[dateFormatter release];
这里的结果在调试器:
2010-07-16 08:15:35.741 MyApp[75003:207] Date CV: 07/16/2010 04:21:00 +00:00
2010-07-16 08:15:35.742 MyApp[75003:207] Date: (null)
2010-07-16 08:15:35.745 MyApp[75003:207] Date CV: 07/16/2010 01:09:26 +00:00
2010-07-16 08:15:35.749 MyApp[75003:207] Date: (null)
任何帮助表示赞赏!谢谢。