Last active
February 29, 2020 05:57
-
-
Save kishikawakatsumi/b5fe2ebddea11f0dfdd15299e7618ed8 to your computer and use it in GitHub Desktop.
Executing asynchronous tasks sequentially in Swift
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 q = DispatchQueue(label: "q") | |
let group = DispatchGroup() | |
group.enter() | |
q.async { | |
loadA(completion: { | |
// Do something... | |
group.leave() | |
}) | |
} | |
q.async { | |
group.wait() | |
group.enter() | |
loadB(completion: { | |
// Do something... | |
group.leave() | |
}) | |
} | |
q.async { | |
group.wait() | |
group.enter() | |
loadC(completion: { | |
// Do something... | |
group.leave() | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment