The following iOS playground snippet:
import UIKit
// let urlPath = "http://ip.jsontest.com"
let urlPath = "https://api.github.com/repos/vmg/redcarpet"
var url = NSURL(string: urlPath)
var request: NSURLRequest = NSURLRequest(URL: url!)
var response: NSURLResponse?
var error: NSError?
var dataVal = NSURLConnection.sendSynchronousRequest(request, returningResponse: &response, error:&error)
if error == nil {
println(response)
} else {
println(error)
}
Correctly prints the response for the HTTP url, but says that the HTTPS url has a certificate error. I've tried three different sites that I know have valid certificates. Any idea what's wrong?
It looks like this is an iOS playground bug. In an OSX playground, both URLs work, and both work in a real iOS app. So, this is apparently just a playground issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.