Created
February 1, 2020 06:19
-
-
Save palaniraja/197fe8870c12356e898d622b20a700bc to your computer and use it in GitHub Desktop.
dispatchgroup swift playground
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
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