I'm trying to access an API I made in PHP. It works fine in browser, but I can't get this code to fetch any sort of data from any given webpage.
var jsonData: NSData = NSData(contentsOfURL: NSURL(string: "http://www.google.com"))
let string1 = NSString(data: jsonData, encoding: NSUTF8StringEncoding)
println(string1)
What am I doing wrong here?
Update: Here's the output after changing encoding.
Also, NSURLConnection doesn't start when I do that either. Might be a related issue.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…