更新:我能够将日期从服务器 json 转换为 2012/09/05 10:45
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 而我的 This is the timesArray is () 我不明白出了什么问题。谢谢您的帮助。