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

标签 swift networking parse-platform

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

相关文章:

java - Android-ParseQuery- HashMap : Hashmap stays empty?

swift - 如何快速检查主线程上的通知权限?

ios - 使用 float 抽屉交换中心 View Controller

ios - Reachability.h bool 变量 connectionRequired——这是什么意思?

python - 有没有办法使用系统默认网关以外的其他网关在 python 中发出 http 请求?

ios - 方法需要启用固定

Swift - 软键盘不会出现或硬件键盘不起作用

ios - 如何将场景切换到导航 Controller 堆栈的几层?

c# - 套接字仅捕获传出数据包,而不捕获传入数据包

ios - 解析本地数据存储不一致