views:

99

answers:

2

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

+1  A: 

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
+2  A: 

Take a look at my answer on this question:

http://stackoverflow.com/questions/3220695/nstimer-problem/3220828#3220828

It's very similar to what you are asking for.

Darryl H. Thomas
That is awesome thanks. What if I wanted to have a pause button, how will the timer be paused?
alJaree
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