You must use the send groups included in the group before issuing the request and leaving the group in the completion handler for the request. So, suppose for a second you had some method that performed an asynchronous request, but provided a completion handler parameter, which was a closure that would be called when the network request was executed:
func perform(request: URLRequest, completionHandler: @escaping () -> Void) { ... }
To run these two simultaneous requests and get notified when they are done, you will do something like:
let group = DispatchGroup()
group.enter()
perform(request: first) {
group.leave()
}
group.enter()
perform(request: second) {
group.leave()
}
group.notify(queue: .main) {
print("both done")
}
, perform(request:) (, ), , , URLSession Alamofire. GCD, .