Created
December 15, 2016 09:16
-
-
Save ArchieGoodwin/6d2d8f978c2921cfc59d94e4f75fc17d to your computer and use it in GitHub Desktop.
group dispatch in swift 3
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 backgroundQ = DispatchQueue.global(attributes: .qosDefault) | |
let group = DispatchGroup() | |
var someData:[Data] = [] | |
for number in 0..<n { | |
group.enter() | |
backgroundQ.async(group: group, execute: { | |
if number > 50 { | |
fill.append(number) | |
} | |
group.leave() | |
}) | |
} | |
group.notify(queue: DispatchQueue.main, execute: { | |
print("All Done"); completion(result: fill) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment