url = NSURL(string: "https://www.nsscreencast.com/api/episodes.json") var task = session.dataTaskWithURL(url) { (let data, let response, let error) in // ... }
url = NSURL(string: "https://www.nsscreencast.com/api/episodes.json") var task = session.dataTaskWithURL(url) { (let data, let response, let error) in // ... } // don't forget to trigger the request task.resume()
{ // have we started loading a different image yet? if self.imageTask?.state == NSURLSessionTaskState.Canceling { return } let image = UIImage(data: data) dispatch_async(dispatch_get_main_queue()) { self.image = image } } else { println("\(url) received HTTP \(http.statusCode)") }