Last active
October 11, 2019 10:17
-
-
Save 92pino/790501323f8ead0de6c67b89a619d469 to your computer and use it in GitHub Desktop.
Delicious Interview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let url = URL(string: "https://httpbin.org/get")! | |
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in | |
if let error = error { | |
print("error : "\(error.localizedDescription)") | |
} else { | |
if let response = response as? HTTPURLResponse { | |
print("statusCode : \(response.statusCode)") | |
} | |
if let data = data, let dataString = String(data: data, encoding: .utf8) { | |
print("data : \(dataString)") | |
} | |
} | |
} | |
task.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment