Last active
August 17, 2019 14:17
-
-
Save standinga/9785bed4f53a7a8486a098a727e1e190 to your computer and use it in GitHub Desktop.
fetchData function for medium blog post about DispatchGroup and DispatchSemaphore, https://link.medium.com/zJMQPUHaeZ
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 combineAsyncCalls(completionHandler: @escaping (String)->()) { | |
var text = "" | |
fetchData(0, delay: 0.4) { text += $0 } | |
fetchData(1, delay: 0.2) { text += $0 } | |
completionHandler(text) | |
} | |
combineAsyncCalls() { | |
print($0) | |
exit(0) | |
} | |
RunLoop.current.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment