gpt4 book ai didi

swift - NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802)

转载 作者:搜寻专家 更新时间:2023-10-31 08:11:33 25 4
gpt4 key购买 nike

我收到错误:NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802),我怀疑这是因为从 Parse 查询图像。这是我查询的方法:

func fetchImageForEmployee(employee: PFEmployee, completion: (error: String?, image: UIImage?) -> Void) {
if (employee.profilePicture == nil) {
completion(error: "No image file", image: nil)
} else {
employee.profilePicture!.getDataInBackgroundWithBlock({ (data, error) -> Void in
if let error = error {
let errorString = error.userInfo["error"] as? String
completion(error: errorString, image: nil)
} else if (data != nil) {
let image = UIImage(data: data!)
completion(error: nil, image: image)
} else {
completion(error: nil, image: nil)
}
})
}
}

我还打印了错误,这就是调试器中出现的错误:不允许在释放时尝试加载 View Controller 的 View ,这可能会导致未定义的行为(UISearchController:0x13ee44dc0)

我不知道出了什么问题,所以感谢所有答案。

最佳答案

右键单击您的 Info.plist 文件 > 打开为 > 源代码,并在最新的 </dict> 之前添加以下内容:

<key>NSAppTransportSecurity</key>  
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>

在 iOS9 中,ATS 在网络调用期间强制执行最佳实践,包括使用 HTTPS。在 Apple Documentation 中阅读更多相关信息.

关于swift - NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30927368/

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