多点连接IOS:didFinishReceivingResourceWithName错误处理(崩溃)
我一直在努力尝试在相对较短的时间内让多个EER连接在我们的应用程序中工作。大多数事情进展得相当顺利,但我们现在遇到了一个非常令人费解的问题 我们在沿着愉快的路径传输所有数据时都很好,但在尝试执行错误处理时。。。这是通过关闭wifi中间传输来实现的。。我的密码…: 共享者:多点连接IOS:didFinishReceivingResourceWithName错误处理(崩溃),ios,swift,multipeer-connectivity,Ios,Swift,Multipeer Connectivity,我一直在努力尝试在相对较短的时间内让多个EER连接在我们的应用程序中工作。大多数事情进展得相当顺利,但我们现在遇到了一个非常令人费解的问题 我们在沿着愉快的路径传输所有数据时都很好,但在尝试执行错误处理时。。。这是通过关闭wifi中间传输来实现的。。我的密码…: 共享者: func sendResource(data: Data?, name: String, fileName: String, peerId: MCPeerID){ if data != nil{
func sendResource(data: Data?, name: String, fileName: String, peerId: MCPeerID){
if data != nil{
let url = createTransferFile(jsonData: data!, name: fileName)
if url != nil{
session.sendResource(at: url!, withName: name, toPeer: peerId, withCompletionHandler: { (error) -> Void in
if error != nil{
NSLog("Error in sending resource send resource: \(error!.localizedDescription)")
}
})
}
}
}
接收人:
func session(_ session: MCSession, didFinishReceivingResourceWithName resourceName: String, fromPeer peerID: MCPeerID, at localURL: URL, withError error: Error?) {
NSLog("%@", "didFinishReceivingResourceWithName: \(resourceName)")
if error != nil{
NSLog("error in receiving")
}
if resourceName.contains("clinicDetails"){
if error == nil{
if let data = self.readClinicJsonFromFile(path: localURL){
NSLog("passing to broadcast delegate")
sendDelegate?.addClinicDetails(self, clinicDetailsJSON: data)
}else{
NSLog("there was an error in finding the retrieved file in clinic retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else if resourceName.contains("patients"){
//NSLog("clinicId in retrievePatient: \(json["clinicId"])")
if error == nil{
if let data = self.readPatientJsonFromFile(path: localURL){
NSLog("passing to retrieve patients delegate")
retrievePatientDelegate?.addPatients(self, patientJSON: data , clinicId: resourceName.components(separatedBy: "/")[1])
}else{
NSLog("there was an error in finding the retrieved file in patient retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else if resourceName == "clinicList"{
if error == nil{
if let data = self.readClinicListJsonFromFile(path: localURL){
NSLog("passing to retrieve retrieveDelegate")
retrieveDelegate?.addClinics(self, clinicsJSON: data["jsonData"] as! [[String:Any]], passcode: data["passcode"] as! String)
}else{
NSLog("there was an error in finding the retrieved file in patient retrieve finished")
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}else{
_ = Util.showAlert(retrievePatientDelegate as! UIViewController, code: 3021, actions: nil, isCustom: true) as! AlertController
}
}
}
我们收到的错误:
2017-03-06 16:52:54.416352 DC[2445:1444277] [GCKSession] Failed to send a DTLS packet with 78 bytes; sendmsg error: Can't assign requested address (49).
2017-03-06 16:52:54.416560 DC[2445:1444277] [GCKSession] SSLWrite failed, packet was not sent for participant [05280B9E] channelID [4] DTLS context [0x103043ea0] pCList [0x10e94f960]; osStatus = -9803: errno = Can't assign requested address (49).
这些行根据剩余的进度打印出更多内容
(我还不能将图像直接添加到我的帖子中:<)
由于didFinishReceivingResourceWithName函数中的localURL不是可选的,因此此错误似乎与Apple框架中的错误有关。错误或进度取消的值为零。在查看崩溃线程中的每个调用并找到相关的后,我得出了这个结论。您可以共享该跟踪中的堆栈帧吗?当线程崩溃时,它正在运行什么代码?好的,我会这样做。堆栈帧是什么意思?是否要我向您发送调试器会话的屏幕截图?还是有更好的发送方式@Davewston在Xcode左侧的面板中,其中一个将显示在崩溃中结束的堆栈帧。它将列出崩溃发生时执行的所有方法,最新的方法位于顶部。然后我们想看看你写的触发崩溃的代码。您共享的图像中有崩溃实际发生的机器代码,但这并没有告诉我们我们是如何到达那里的。@Davewston嘿,我附加了导致崩溃的线程的堆栈框架。。这够好吗,还是你需要所有的线?