我在做
if !UIApplication.shared.openURL(url) {
print("Error")
}
问题是,我在控制台中看到了错误信息,我想知道是什么具体的HTTP错误被抛出。
你可以得到你的回应,做这样的事情。
let URL = URL(string: "www.google.com")
let task = URLSession.shared.dataTask(with:url!) { _, response, _ in
if let status = response as? HTTPURLResponse {
print(status.statusCode)
}
}
task.resume()
任何语法问题道歉。目前没有XCode可用。