ios - Why isn't my NSTimer calling my method upon expiration? -


i using nstimer call method titled lose. had timer when ran out, called lose, lost due hard drive error. after trying code again, can't seem method called.

timer = [nstimer timerwithtimeinterval:timemax target:self selector:@selector(lose) userinfo:nil repeats:no]; 

lose declared in .h file, this:

-(void)lose; 

also, method looks this:

-(void)lose{  text.hidden = no; scorelabel.hidden = no; target.hidden = yes; targetx.hidden = yes;   if (score > highscorenumber) {     highscoreachieved.hidden = no;     highscorenumber = score;     }  } 

the variable timemax int declared in .h file, last time. whenever target tapped in game, timemax becomes .03 seconds shorter. this:

timemax = 5 - (score * 0.03); 

i don't remember looking different before massive hardware failure, why isnt working?

you have schedule timer on run loop or use line instead schedules you:

timer = [nstimer scheduledtimerwithtimeinterval:timemax                                          target:self                                        selector:@selector(lose)                                        userinfo:nil                                         repeats:no]; 

it's idea code...which reminds me.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -