iphone - How to pause and resume NStimer -


possible duplicate:
how can programmatically pause nstimer?

i have question. how can pause countdown using timer? developing game. in game, need go next view when timer pauses, , after coming want resume it.

i try code in view:

[mytimer pause];  // resume [mytimer resume]; 

i try code, warning saying: "nstimer may not respond 'pause'"

i build warning , when press pause button, app crashes.

nstimer indeed doesn't have resume , pause methods can end crash in runtime after such warning. can create 2 kinds of timers (see nstimer class reference) 1 implements once , second, repeats. example:

this way create timer, enter callback mymethod each second.

nstimer *mytimer = [nstimer scheduledtimerwithtimeinterval:1      target:self      selector:@selector(mymethod:)      userinfo:nil      repeats:yes]; 

you choose 1 purpose in class should maintain

bool pausevariable , in callback mymethod following:

 - (void) mymethod:(nstimer *) atimer {      if (!pause) {        //        // update gui      } } 

where update pause accordingly somewhere in code. stop timer (and release it) call

 [mytimer invalidate]; 

good luck


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

sql server - python to mssql encoding problem -

windows - Python Service Installation - "Could not find PythonClass entry" -