当我向nsdate添加时间间隔时,它不会添加
dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setTimeZone:[NSTimeZone defaultTimeZone]];
[dateFormat setDateFormat:@"ss"];
dateString = [dateFormat stringFromDate:app.currentDate];//app.currentDate means nsdate
NSLog(@"%@",dateString);
[defaults setObject:dateString forKey:@"Default_second"];
NSTimeInterval timeInter = [[defaults objectForKey:@"Default_second"]doubleValue];
NSLog(@"%f--",timeInter);
[app.currentDate dateByAddingTimeInterval:-timeInter];
答案 0 :(得分:1)
我认为您应该将app.currentDate设置为:
[app setCurrentDate: [app.currentDate dateByAddingTimeInterval:-timeInter]];