Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typealias CallBack = (result: [Int]) -> Void
- func longCalculations (completion: CallBack) {
- let backgroundQ = DispatchQueue.global(attributes: .qosBackground)
- let group = DispatchGroup()
- var fill:[Int] = []
- for item in 0...200 {
- group.enter()
- if item > 50 {
- fill.append(item)
- }
- group.leave()
- }
- group.notify(queue: DispatchQueue.main, execute: {
- completion(result: fill)
- })
- }
- longCalculations() { print($0) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement