NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802) [英] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802)

查看:20
本文介绍了NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am getting the error: NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9802), and I suspect that it is because of querying for images from Parse. Here is the method where I am querying:

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

我还打印了错误,这就是调试器中出现的内容:不允许在解除分配时尝试加载视图控制器的视图,并且可能会导致未定义的行为 (UISearchController: 0x13ee44dc0)

I also printed the error, and this is what appeared in the debugger: Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior (UISearchController: 0x13ee44dc0)

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

I don't know what is going wrong, so all answers are appreciated.

推荐答案

右击你的Info.plist文件>打开为>源代码,在最新的</dict> :

Right click on your Info.plist file > Open As > Source Code, and add the following before the latest </dict> :

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

在 iOS9 中,ATS 在网络调用期间强制执行最佳实践,包括使用 HTTPS.在 Apple 文档.

In iOS9, ATS enforces best practices during network calls, including the use of HTTPS. Read more about it in the Apple Documentation.

这篇关于NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9802)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆