iphone - Check if NSTimeInterval equals 0 -
//gets time right nsdate *now = [nsdate date]; //stores difference in seconds between when test started , now. nstimeinterval interval = [self.expires timeintervalsincedate:now]; if (interval == 0) { ... }
any reason why condition wont true?
thanks.
since nstimeinterval
double
, might have floating point rounding error. try using
if (abs(interval) < eps) {
where eps
small enough constant.
or, if want know seconds , not milliseconds, can truncate double int.
but judging code, think might want check if timeline has already expired, not expires @ exact moment. probability of later small. should trick.
if (interval < 0) {
Comments
Post a Comment