Objective C 相当于 javascripts setTimeout? [英] Objective C equivalent to javascripts setTimeout?
本文介绍了Objective C 相当于 javascripts setTimeout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否有解决方案可以在 CocoaTouch ObjectiveC 中在 30 秒或每 30 秒后引发一次事件.
I was wondering whether there is a solution to raise an event once after 30 seconds or every 30 seconds in CocoaTouch ObjectiveC.
推荐答案
有多种选择.
最快的使用在NSObject
:
The quickest to use is in NSObject
:
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay
(还有一些略有不同.)
(There are a few others with slight variations.)
如果您想要更多的控制权或能够说每三十秒发送一次此消息,您可能需要 NSTimer
.
If you want more control or to be able to say send this message every thirty seconds you probably need NSTimer
.
这篇关于Objective C 相当于 javascripts setTimeout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文