import Foundation var todos = [String: Any]() let dispatchGroup = DispatchGroup() for todo in 0..10 { let url = URL(string: "https://jsonplaceholder.typicode.com/todos/\(todo)") dispatchGroup.enter() let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in let jsonSerialized = try! JSONSerialization.jsonObject(with: data, options: []) as? [String : Any] todos += [jsonSerialized] // do more stuff // ready to end processing on this particular async task? dispatchGroup.leave() } task.resume() } dispatchGroup.notify(queue: DispatchQueue.main) { print("Got \(todos.count) todos!") // other stuff including display on screen }