0

I have read some docs on NSTimer and havent quite seen what I am looking for.

I would like to know how to write an NSTimer which will repeat every 1 sec or another time value(maybe have this value as parameter) and the overall repeat should repeat for one minute.

Also how is this overall time (1 minute) shown on screen , maybe in a UILabel?

Thanks

some_id
  • 29,466
  • 62
  • 182
  • 304
  • Take a look at my answer on this question: https://stackoverflow.com/questions/3220695/nstimer-problem/3220828#3220828 It's very similar to what you are asking for. – Darryl H. Thomas Jul 22 '10 at 13:23
  • That is awesome thanks. What if I wanted to have a pause button, how will the timer be paused? – some_id Jul 22 '10 at 14:42
  • Basically, you would invalidate the timer (and set the ivar to nil) in your pause action and schedule a new timer in your resume action. In these cases you wouldn't want to reset the "remainingTicks" value. – Darryl H. Thomas Jul 22 '10 at 15:05

1 Answers1

1

That's exactly what NSTimer does. You need to invalidate the timer yourself after a minute has passed though. Just keep count of the number of invocations and when you hit 60 you invalidate the timer.

NSTimer

NSTimer Programming Guide

willcodejavaforfood
  • 43,223
  • 17
  • 81
  • 111