Last active
November 29, 2018 14:09
-
-
Save candostdagdeviren/631aa7d7d83935f55e8a233d22803774 to your computer and use it in GitHub Desktop.
Swift Post Concurrency Blog Post Code Example
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://theswiftpost.co/") | |
if let url = url { | |
showLoadingIndicator() // UI Operation; has to run on the main queue | |
let task = URLSession.shared.dataTask(with: url) { (data, response, error) in | |
if error != nil { | |
showErrorAlert(error) // UI operation; has to run on the main queue!! | |
} else if let data = data { | |
debugPrint(usableData) //JSONSerialization | |
} | |
debugPrint(“Completed”) | |
} | |
} | |
task.resume() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment