Simple timer in iPhone
<p>I'm trying to use timeIntervalSinceReferenceDate and I'm not quite sure if I understand it correctly.  I basically have a button to calculate the difference in time between when the start and stop button is pressed.</p>

<pre><code>- (IBAction)startButtonPressed {
    startButtonFlag = !startButtonFlag; // first time through, startButtonFlag turns on
    if (startButtonFlag) { // timer starts
        [startButton setTitle:@"Stop" forState:UIControlStateNormal];
        startTime = [NSDate timeIntervalSinceReferenceDate];
        NSLog(@"start time: %d", startTime);
    }
    else { // timer stops
        [startButton setTitle:@"Start" forState:UIControlStateNormal]; 
        stopTime = [NSDate timeIntervalSinceReferenceDate];
        NSLog(@"stop time: %d", stopTime);      
        elapsedTime = stopTime - startTime;
        NSLog(@"elapsed time: %d", elapsedTime);
    }

}
</code></pre>

<p>I don't quite understand the output.  My sample output is:
start time: 558828278
stop time: 581239552
elapsed time: -1610612736</p>

<p>I pressed the stop button shortly after (5 seconds or so) after I pressed start.  I was expecting that the stop time would be more like 558828283 so when I subtracted the two times, to see how much time has elapsed, I would get 5 seconds.  Am I misunderstanding how the class method works?  Thanks.</p>
