Objective C相当于javascripts的setTimeout? [英] Objective C equivalent to javascripts setTimeout?
本文介绍了Objective C相当于javascripts的setTimeout?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
我想知道在CocoaTouch ObjectiveC中是否有一个解决方案可以在30秒后或每30秒发生一次事件。 p>有很多选项。
最快使用的是 NSObject
- (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)延迟
(还有其他几个略有变化的)。
如果你想要更多的控制或能够说每隔30秒发送一次这个消息,你可能需要 NSTimer
。
I was wondering whether there is a solution to raise an event once after 30 seconds or every 30 seconds in CocoaTouch ObjectiveC.
解决方案
There are a number of options.
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.)
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屋!
查看全文