Trying to use NSURL and associated classes to read some data from a given url. This is a simple version of what I'm doing:
import Foundation
let urlString = "http://www.google.com"
let nsURL = NSURL(string:urlString)
let task = NSURLSession.sharedSession().dataTaskWithURL(nsURL!) {
(data, response, error) in
print("data=\data(), response=\(response), error=\(error)")
}
task.resume()
The problem I run into is that the completion handler I provide is never called. It builds and runs fine in Xcode 7 but nothing ever prints. I would expect either something to print or somekind of warning.
I've seen this identical question asked elsewhere, but the solution was always that the person had forgotten to call task.resume(). In these cases, the accepted solutions all looked pretty much the same as what I've got above. Failing to start the task is not the problem here, so any ideas what it could be?