如何定期调用目标c中的方法? [英] How to make a periodic call to a method in objective c?
问题描述
如果问题没有解释清楚请原谅我。
我正在开发一个iphone客户端服务器应用程序,我创建了所有的类,实例和ect。我甚至可以发送get和解析响应太..无论如何,现在我需要使我的方法在定义的时间段内被调用(例如,在10秒内重复调用它)。我google了很多,还看看
if the question is not explained clearly please excuse me. I'm developing an iphone Client-Server app, i created all the classes, instances and ect. I can even send get and parse the response too.. Anyway, now i need to make my method be called in a defined period of time(for instance, call it repeatly in 10 seconds). I googled a lot and also take a look at
NSDate 但我不能解决..现在,任何人都可以帮助我如何处理这种情况?非常感谢
NSDate but i couldn't solve.. Now, can anyone please help me how to handle this situation? Thank you very much
推荐答案
您可以创建和计划 NSTimer
在给定的时间间隔上调用您的方法。特别参见以下便利创建方法:
You can create and schedule an instance of NSTimer
to call your method on a given time interval. See in particular the following convenience creation method:
+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)seconds target:(id)target selector:(SEL)aSelector userInfo:(id)userInfo repeats:(BOOL)repeats
这篇关于如何定期调用目标c中的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!