nstimer - My timer is 5 seconds faster per minute! cant find the mistake -
i got displayed min seconds , 1/100 seconds in format 1:12.4
[nstimer scheduledtimerwithtimeinterval:1.0/10 target:self selector:@selector(zeitmessung) userinfo:nil repeats:yes]; -(void)zeitmessung{ zeitmisec +=1; if (zeitmisec==9) { zeitsec+=1; zeitmisec=0; } if (zeitsec==59) { zeitmin +=1; zeitsec =0; } if (zeitsec<10) { nsstring *nsstime = [nsstring stringwithformat:@"%i:0%i.%i",zeitmin,zeitsec,zeitmisec]; lbltime.text= nsstime; }else{ nsstring *nsstime = [nsstring stringwithformat:@"%i:%i.%i",zeitmin,zeitsec,zeitmisec]; lbltime.text= nsstime; } }
your if statments little out, turn on @ .9 seconds , 59 seconds.
you need
if (zeitmisec==10){...}
and
if (zeitsec==60){...}
Comments
Post a Comment