0
    -(void) TimerMethod {
      [session disconnectFromAllPeers];
      timer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(myMethod) userInfo:nil repeats:YES];    
    }

    -(void)myMethod {
      @try {
        GKSession *session1=[[GKSession alloc] initWithSessionID:nil displayName:nil sessionMode: GKSessionModePeer];
        self.session=session1;
        session.disconnectTimeout=6.0;
        [session setDataReceiveHandler:self withContext:nil];
        session.delegate=self;
        session.available=YES; 
      }    
      @catch (NSException * e) {
        //NSLog(@"Exception occured");
        [session disconnectFromAllPeers];
        session=NULL;
        GKSession *session1=[[GKSession alloc] initWithSessionID:nil displayName:nil sessionMode: GKSessionModePeer];    
      }    
    }

デバイスを検索しますが、これらのデバイスの配列を作成したいので、「GKRocket を提案しないでください」と言って申し訳ありません。

4

1 に答える 1

0
NSMutableArray *availablePeers = [[self.session peersWithConnectionState:GKPeerStateAvailable] mutableCopy];
于 2012-01-17T14:49:41.893 に答える