在iPhone中每60秒后调用一个方法 [英] calling a method after each 60 seconds in iPhone
本文介绍了在iPhone中每60秒后调用一个方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个GKSession,当它的对象被创建时,它开始搜索设备的可用性,如
I have created an GKSession and as its object is created, it starts search for availability of devices, as
- (void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state {
我想在每60秒后调用此方法,我该怎么办?
I want to call this method after each 60 seconds, what should I do?
推荐答案
使用 NSTimer
NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 60.0 target: self
selector: @selector(callAfterSixtySecond:) userInfo: nil repeats: YES];
每60.0秒后,iOS会调用以下函数
After each 60.0 second , iOS will call the below function
-(void) callAfterSixtySecond:(NSTimer*) t
{
NSLog(@"red");
}
这篇关于在iPhone中每60秒后调用一个方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文