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

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -