calling a method after each 60 seconds in iPhone

后端 未结 6 1806
我在风中等你
我在风中等你 2020-12-08 07:04

I have created an GKSession and as its object is created, it starts search for availability of devices, as

 - (void)session:(GKSession *)session peer:(NSStri         


        
6条回答
  •  鱼传尺愫
    2020-12-08 07:31

    Use the following code:

     NSTimer* timer = [NSTimer scheduledTimerWithTimeInterval: 60.0 target: self
                                   selector: @selector(timerFired:) userInfo: nil repeats: YES];
    
     - (void)timerFired:(NSTimer*)theTimer{
     if(condition){
           [theTimer isValid]; //recall the NSTimer
           //implement your methods
      }else{
          [theTimer invalidate]; //stop the NSTimer
     }
    }
    

提交回复
热议问题