我收到错误: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/