开发者

How to save Bluetooth available devices into an NSMutableArray?

    -(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 occur开发者_运维问答ed");
        [session disconnectFromAllPeers];
        session=NULL;
        GKSession *session1=[[GKSession alloc] initWithSessionID:nil displayName:nil sessionMode: GKSessionModePeer];    
      }    
    }

Now it will search for devices, but I want to make array of these devices, and sorry to say "Don't suggest me GKRocket, please".


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜