当我向nsdate添加时间间隔时,它将不会添加

时间:2012-02-22 14:59:33

标签: iphone nsdateformatter

当我向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]; 

1 个答案:

答案 0 :(得分:1)

我认为您应该将app.currentDate设置为:

[app setCurrentDate: [app.currentDate dateByAddingTimeInterval:-timeInter]];