I am using the code below.
func getData(url: String) {
if let url = NSURL(string: url) {
do {
let html = try NSString(contentsOfURL: url, encoding: NSUTF8StringEncoding)
print("HTML: \(html)")
} catch {
print("x")
}
}
}
getData("Google.com")
I need help with later printing out the variable 'html' and any other case printing out the error that forced the catch throw. With the current code it prints out "x". I want to print out why it forced that catch I can know what went wrong and why 'html' did not print.