Objective-C : NSTimer and countdown

后端 未结 2 959
甜味超标
甜味超标 2020-12-09 23:44

I know that I should understand Apple\'s documentation for NSTimer, but I don\'t! I have also read a lot of questions about it but can not find one that suites my case. Well

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 00:01

    That's a big order. But start with baby steps. You need to create a method in your class which, when invoked (every N seconds), will update the labels you want updated. Then you arrange for a timer to invoke that method every N seconds.

    There are several timer variants you might use, but for this case the most straight-forward is probably NSTimer scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:.

    Write your method to look like - (void)timerFireMethod:(NSTimer*)theTimer and the selector for the timer method above is @selector(timerFireMethod:).

提交回复
热议问题