更新:我能够从服务器获取JSON转换的日期2012/09/05 10:45混淆NSDateFormatter
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
for (NSString *slotKey in myslots.allKeys) {
NSDictionary *slot = [myslots valueForKey:slotKey];
for (myDays in slot){
if ([[self.myDays objectForKey:@"isReservable"] isEqualToNumber:[NSNumber numberWithInt:1]]){
NSDate *newDate = [df dateFromString:[self.myDays objectForKey:@"begin"]];
if (newDate){
[self.timesArray addObject:newDate];
}
NSLog(@"these are the returned newdates: %@",newDate);
NSLog(@"This is the timesArray: %@", self.timesArray);
}
}
}
我的这些的NSLog仍然返回null,我这是timesArray是() 我不明白什么是错的。谢谢您的帮助。
没有被添加到的NSArray因为日期格式是barfing上你的输入并且给你nil而不是NSDate。看到我更新的答案。 – Clay