NSString encoding returns nil on url content
问题 I'm following an iOS Swift guide on Udemy and this is the first issue I cannot work around: I am supposed to see html etc printed to the console but instead I get null. This is the section: let url = NSURL(string: "https://google.com") let task = NSURLSession.sharedSession().dataTaskWithURL(url!) { (data, response, error) in if error == nil { var urlContent = NSString(data: data!, encoding: NSUTF8StringEncoding) print(urlContent) } } task.resume() If I print just the data then it gives me