I have the following code in my application in the method updateLabel2
:
timeLeft = [[NSDate date] timeIntervalSinceDate:[[NSUserDefaults standardUserDefaults] objectForKey:@"lastDate"]];
[[self timer] setText:[NSString stringWithFormat:@"Time Remaining: %f", timeLeft]]; //Set the label text
Note that timer is a label.
and earlier, the following code is executed:
[[NSUserDefaults standardUserDefaults] setObject:[NSDate date] forKey:@"lastDate"];
self.repeatTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self
selector:@selector(updateLabel2)
userInfo:nil
repeats:YES];
My problem is that timeLeft is being set to random integers which are definetly not what the timeIntervals should be, and are not within one second of each other either.