Esperando que todos los hilos terminen Swift

let group = DispatchGroup()
group.enter()
DispatchQueue.global(qos: .userInitiated).async {
    // Do work asyncly and call group.leave() after you are done
    group.leave()
}
group.notify(queue: .main, execute: {
    // This will be called when block ends             
})
Kanishk Dhindsa