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];
精彩评论