ios - NSDate returns a negative NSTimeInterval -


i have following code:

- (void)pointsstarteddisplaying {     static dispatch_once_t oncetoken;     dispatch_once(&oncetoken, ^{         dispatch_async(dispatch_get_main_queue(), ^{             self.timestarteddisplayingpoint = [nsdate date];             self.stopbutton.enabled = yes;              [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(updateelapsedtime:) userinfo:nil repeats:yes];         });     }); }  - (void)updateelapsedtime:(nstimer *)timer {     nstimeinterval elapsedtimedisplayingpoints = [self.timestarteddisplayingpoint timeintervalsincedate:[nsdate date]];     self.elapsedtimevaluelabel.text = [nsstring stringwithformat:@"%f seconds", elapsedtimedisplayingpoints]; } 

however, value of elapsedtimedisplayingpoints accurate, except negative each time. why return -3, -4, -5, etc?

if receiver earlier anotherdate, return value negative. case example. can use fabs() positive value.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -