December 2018
Intermediate to advanced
414 pages
10h 19m
English
Let's take a look at the anatomy of a simple URL task:
let url = URL(string: "https://api.website.com/")!let task = URLSession.shared.dataTask(url: url) { data, response, error in if let error = error { return } // handle the error somehow guard let response = response as HTTPURLResponse, let data = data else { return } // data: Data is set, and all good}task.resume()
If the call has succeeded, the data variable will be set and will contain the data downloaded from the remote server.
Read now
Unlock full access