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

查看:99
本文介绍了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天全站免登陆