2012-05-27 87 views
2

我正在编程一个节拍器应用程序,它通过GameKit和PeerPickerController建立蓝牙连接,然后允许一个设备通过另一个设备发送控件,因此如果启动按下一个设备,节拍器都启动。iOS上的蓝牙连接 - 应用程序在建立连接时崩溃

应用程序加载罚款和其他设备搜索并表示,其连接在Xcode的调试窗口,但随后这个错误立即崩溃:

wait_fences: failed to receive reply: 10004003

2012-05-27 20:51:50.820 MetroConnect[5689:707] -[MetroConnectViewController session:didFailWithError:]: unrecognized selector sent to instance 0x1793f0 2012-05-27 20:51:50.824 MetroConnect[5689:707] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MetroConnectViewController session:didFailWithError:]: unrecognized selector sent to instance 0x1793f0' * First throw call stack: (0x3126388f 0x375a1259 0x31266a9b 0x31265a83 0x311c0650 0x34141b5f 0x311c21fb 0x31b7f747 0x31237ad3 0x3123729f 0x31236045 0x311b94a5 0x311b936d 0x33233439 0x3091ccd5 0x5023 0x4fc8) terminate called throwing an exception(lldb)

我想知道如果有人能告诉我在哪儿会出错吗?我以类似的方式制作了一个不同的应用程序,可以在两台设备之间发送聊天消息,并且工作正常,我看不出这个实现与节拍器实现之间有什么区别。

回答

0

看起来好像你是GKSession委托,但不实现所需的委托方法。毕竟,它们是有原因的。像这样的东西的方法,并检查你有他们的其他实施得当:实现会话:didFailWithError

- (void)session:(GKSession *)session didFailWithError:(NSError *)error { 
    NSLog(@"Session connection failed with error %@",[error localizedDescription]); 
} 
+0

好了,所以我实现了上面的代码,然后得到这个错误: 会话连接失败,错误无效参数-setDataReceiveHandler:withContext: 我找到了在peerPickerController方法中引用的代码行。这是与方法名称: ' - (无效)peerPickerController:(GKPeerPickerController *)选择器didConnectPeer:(的NSString *)的peerID到会议:(GKSession *)session' '[会议setDataReceiveHandler:自withContext:无] ;' 任何想法这个错误可能意味着什么?非常感谢你的帮助。 @CodaFi – user1420540