如何将蓝牙可用设备保存到NSMutableArray中?

时间:2011-04-13 13:00:32

标签: iphone cocoa-touch gksession

    -(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”。

1 个答案:

答案 0 :(得分:0)

NSMutableArray *availablePeers = [[self.session peersWithConnectionState:GKPeerStateAvailable] mutableCopy];