swift – NSURLSession / NSURLConnection HTTP加载失败(kCFStre
发布时间:2020-12-14 02:29:05 所属栏目:百科 来源:网络整理
导读:我收到错误:NSURLSession / NSURLConnection HTTP加载失败(kCFStreamErrorDomainSSL,-9802),我怀疑这是因为查询来自Parse的图像.这是我查询的方法: func fetchImageForEmployee(employee: PFEmployee,completion: (error: String?,image: UIImage?) - Void
我收到错误: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中了解更多相关信息. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |