Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Created February 1, 2020 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save palaniraja/197fe8870c12356e898d622b20a700bc to your computer and use it in GitHub Desktop.
Save palaniraja/197fe8870c12356e898d622b20a700bc to your computer and use it in GitHub Desktop.
dispatchgroup swift playground
import UIKit
print("one")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
print("two")
}
print("three")
func testactivation(){
var complete = false
var dg = DispatchGroup()
for i in 0 ..< 5 {
if i > 2 {
break
}
dg.enter()
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(2 + i) ) {
print("ii: \(i)")
dg.leave()
}
}
dg.notify(queue: DispatchQueue.main){
print("post action")
}
}
testactivation()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment