gpt4 book ai didi

ios - 多点连接 IOS : didFinishReceivingResourceWithName Error Handling (Crash)

转载 作者:可可西里 更新时间:2023-11-01 02:06:21 26 4
gpt4 key购买 nike

我一直在努力尝试在相对较短的时间内让 Multipeer Connectivity 在我们的应用程序中运行。大多数事情都进行得相当顺利,但我们现在遇到了一个非常令人费解的问题。

当遵循快乐的路径时,我们可以很好地传输所有数据,但是当尝试实现错误处理时......这是通过关闭 wifi 传输中完成的......我的代码......:

分享者:

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).

这些行会根据剩余的进度打印出更多内容。

Then we also get the following stack in xcode (我还不能将图片直接添加到我的帖子中:<)

Stack Frame from the thread causing the error

最佳答案

由于 didFinishReceivingResourceWithName 函数中的 localURL 不是可选的,因此该错误似乎与 apples 框架中的错误有关。错误或取消进度的值为 nil。在查看崩溃线程中的每个调用然后找到相关的 SO Post 之后,我得出了这个结论。

关于ios - 多点连接 IOS : didFinishReceivingResourceWithName Error Handling (Crash),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42656331/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com