Last active
March 4, 2019 23:25
-
-
Save novinfard/e006e47820a2d3e48769ded9b6487399 to your computer and use it in GitHub Desktop.
[Syncing multiple async tasks in Swift - code snippets 1]
This file contains hidden or 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
func performNetworkRequest(url: String, | |
completion: @escaping (Data?, Error?) -> Void) { | |
// create a url | |
let requestUrl = URL(string: url) | |
// create a data task | |
let task = URLSession.shared.dataTask(with: requestUrl!) { (data, response, error) in | |
completion(data, error) | |
} | |
task.resume() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment