Skip to content

Instantly share code, notes, and snippets.

@deda9
Last active June 12, 2018 22:36
Show Gist options
  • Save deda9/32a191ca05a248ee0ffa95eecc5f2bbd to your computer and use it in GitHub Desktop.
Save deda9/32a191ca05a248ee0ffa95eecc5f2bbd to your computer and use it in GitHub Desktop.
How to create DispatchGroup
let group = DispatchGroup()
group.enter()
let dispatchQueue1 = DispatchQueue.init(label: "dispatchQueue")
dispatchQueue1.sync {
for i in 0..<5 {
print("DispatchQueue X ", i)
}
group.leave()
}
group.enter()
dispatchQueue1.sync {
for i in 0..<5 {
print("DispatchQueue Y ", i)
}
group.leave()
}
group.notify(queue: dispatchQueue1){
print("Dispatch group finished the work")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment