开发者

How to use NSTimer with creating but not running?

I have one problem开发者_如何学运维: when i create NSTimer with:

NSTimer *some_timer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(gamePlay) userInfo:nil repeats:YES];

I have a problem, my timer is immediately run.

How i need to write code to create timer, but run and start when it need, with some method???


Create it using +alloc/-initWithFireDate:interval:target:selector:userInfo:repeats:, with a fire date far in the future, and send it a -setFireDate: message when you want it to start.

What I'm not understanding about your question is why you want to create the timer before you need it do to anything?


You need to move this code to the event that you would fire on your "run and start when it need".

If you want to start after a defined period, then the solution of NSResponder would suffice your needs.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜