Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the Swift equivalent for dispatch_group_create

How do I wait for several methods to be completed?

This is the objective-c solution:

self.dispatch_group = dispatch_group_create();
dispatch_group_notify(self.dispatch_group, dispatch_get_main_queue(), ^{
});
dispatch_group_leave(strongSelf.dispatch_group); 
like image 744
fabian Avatar asked Jun 17 '14 20:06

fabian


1 Answers

In Swift 3...

let dispatchGroup = DispatchGroup()

dispatchGroup.enter()

dispatchGroup.leave()

dispatchGroup.notify(queue: DispatchQueue.main) {...}

https://developer.apple.com/reference/dispatch/dispatchgroup

like image 58
CodeOverRide Avatar answered Oct 14 '22 08:10

CodeOverRide