0
我有一個問題,當我使用此代碼GKPeerPickerController而GKSession而GKPeerConnectionStateGKPeerPickerController棄用
我得到的是錯誤:GKPeerPickerController被棄用:在IOS第一棄用7
我的代碼是:
-(void) receiveData:(NSData *)data fromPeer:(NSString *)peer inSession:(GKSession *)session context:(void *)context { NSKeyedUnarchiver *archiver=[[NSKeyedUnarchiver alloc]initForReadingWithData:data]; NSString *str=[archiver decodeObjectForKey:@"Text"]; [self adicionarTexto:str fuiEu:NO]; } -(void)peerPickerController:(GKPeerPickerController *)picker didConnectPeer:(NSString *)peerID toSession:(GKSession *) session { currentSession = session; session.delegate = self; [session setDataReceiveHandler:self withContext:nil]; picker.delegate = nil; [picker dismiss]; } -(void)peerPickerControllerDidCancel:(GKPeerPickerController *)picker{ picker.delegate = nil; conectado=NO; } -(void)session:(GKSession *)session peer:(NSString *)peerID didChangeState:(GKPeerConnectionState)state { if (state==GKPeerStateConnected) { conectado=YES;
}else{
conectado=NO;
}
[self atualizarBarra];
}
和
-(void)peerPickerController:(GKPeerPickerController *)picker didConnectPeer:(NSString *)peerID toSession:(GKSession *) session {
currentSession = session; session.delegate = self; [session
setDataReceiveHandler:self withContext:nil]; picker.delegate = nil;
[picker dismiss]; }
而且
-(void)conectar{ if (conectado==NO) { BTpicker = [[GKPeerPickerController alloc] init]; BTpicker.delegate = self; BTpicker.connectionTypesMask = GKPeerPickerConnectionTypeNearby; [BTpicker show]; }else { [currentSession disconnectFromAllPeers]; } }
請我需要快速幫助:(