微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

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

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

我不知道出了什么问题,所以所有答案都值得赞赏.

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

在iOS9中,ATS在网络呼叫期间实施最佳实践,包括使用HTTPS.在Apple Documentation中了解更多相关信息.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐