title: why am i getting negative values for my timeinterval?
body: <p>I have no idea what is happening. I am trying to make a timer that works by comparing dates. When I start the timer, sometimes it works and then randomly stops, and sometimes it just returns the value of the timeInterval. It seems to only work correctly when the time interval is negative. This is my method:</p>
  
  <pre><code>-(IBAction)startTimer:(id)sender{
      if (timer == nil) {
          [startButton setTitle:@"Start" forState:UIControlStateNormal];
          timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(timerAction:) userInfo:nil repeats:YES];
          date = [NSDate dateWithTimeIntervalSinceNow:testTask.timeInterval]; //instance variable
      } else {
          [startButton setTitle:@"Stop" forState:UIControlStateNormal];
          [timer invalidate];
          timer = nil;
      }
  
  }
  -(void)timerAction:(NSTimer *)t
  {
      NSDate *currentDate = [NSDate date];
      NSTimeInterval updatedTimeInterval = [date timeIntervalSinceDate:currentDate];
      if (updatedTimeInterval &gt; 0){
          if (self.timer)
          {
              [self timerExpired];
              [self.timer invalidate];
              self.timer = nil;
          }
      }
      else
      {
          testTask.timeInterval = updatedTimeInterval;
          NSLog(@"%.2f", testTask.timeInterval);
          NSError *error;
          if (![self.context save:&amp;error]) {
              NSLog(@"couldn't save: %@", [error localizedDescription]);
          }
      }
      NSUInteger seconds = (NSUInteger)round(testTask.timeInterval);
      NSString *string = [NSString stringWithFormat:@"%02u:%02u:%02u",
                          seconds / 3600, (seconds / 60) % 60, seconds % 60];
      timerLabel.text = string;
      NSLog(@"%f", testTask.timeInterval);
  }
  </code></pre>