我编写了这个例子但使用另一台服务器.
http://andrewmarinov.com/parsing-json-swift-4/
我将收到一个Json文件,但我收到错误: TIC SSL信任错误 SURLSession/NSURLConnection HTTP加载失败
我无法改变服务器上的任何内容!
我可以在swift 4/IOS11中使用一些代码来修复它吗?这是我更改的Plist:
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Run Code Online (Sandbox Code Playgroud)
谢谢!
小智 1
我写了这段代码,它们为我工作
func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodClientCertificate) {
completionHandler(.rejectProtectionSpace, nil)
}
if (challenge.protectionSpace.authenticationMethod == NSURLAuthenticationMethodServerTrust) {
let credential = URLCredential(trust: challenge.protectionSpace.serverTrust!)
completionHandler(.useCredential, credential)
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5630 次 |
最近记录: |