Advertisement
Guest User

Untitled

a guest
Jul 24th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. typealias CallBack = (result: [Int]) -> Void
  2. func longCalculations (completion: CallBack) {
  3.  
  4. let backgroundQ = DispatchQueue.global(attributes: .qosBackground)
  5.  
  6. let group = DispatchGroup()
  7. var fill:[Int] = []
  8. for item in 0...200 {
  9. group.enter()
  10. if item > 50 {
  11. fill.append(item)
  12. }
  13. group.leave()
  14. }
  15.  
  16. group.notify(queue: DispatchQueue.main, execute: {
  17. completion(result: fill)
  18. })
  19. }
  20.  
  21.  
  22. longCalculations() { print($0) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement