开发者

NSTimer where code repeats every (some time value in seconds) for 1 minute [duplicate]

开发者 https://www.devze.com 2023-01-08 04:30 出处:网络
This question already has answers here: NSTimer problem (2 answers) Closed 3 years ago开发者_如何学运维.
This question already has answers here: NSTimer problem (2 answers) Closed 3 years ago开发者_如何学运维.

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号