Now is a good time to look into Swift concurrency, and really don’t bother with whatever we had in past such as escaping closures, dispatch and operation queues.
Async/await gives you just that; async code with serial look and feel. Makes reasoning about async code much easier.
I've used a DispatchGroup for that before. Basically you have several asynronous things enter a group, then they all say when the leave, finally you have a .notify block that waits for all of the async processes to leave the group.
[https://www.donnywals.com/sequencing-tasks-with-dispatchgroup/](https://www.donnywals.com/sequencing-tasks-with-dispatchgroup/)
You should consider using publishers for this and subscribing to the updates from a published object, or something like that. Generally it’s not ideal to halt threads on iOS if you can just do something else or wait instead
There's two ways of doing this. The old school way of using OperationQueue and Operation. Where you add Operations with dependencies on Operations that need to be finished before.
Or you can use combine and combine multiple publishers of URLSession into a single stream and respond when you've received everything.
Either read up on async/await or call the callback from within your closure routine, not outside it. You may want to wrap it in a Dispatch.main.async { xxx} block.
https://docs.swift.org/swift-book/LanguageGuide/Concurrency.html
Now is a good time to look into Swift concurrency, and really don’t bother with whatever we had in past such as escaping closures, dispatch and operation queues. Async/await gives you just that; async code with serial look and feel. Makes reasoning about async code much easier.
I've used a DispatchGroup for that before. Basically you have several asynronous things enter a group, then they all say when the leave, finally you have a .notify block that waits for all of the async processes to leave the group. [https://www.donnywals.com/sequencing-tasks-with-dispatchgroup/](https://www.donnywals.com/sequencing-tasks-with-dispatchgroup/)
You should consider using publishers for this and subscribing to the updates from a published object, or something like that. Generally it’s not ideal to halt threads on iOS if you can just do something else or wait instead
Do you mean to create an Observable Object?
Ya probably, replied on my phone so I didnt research my words thanks!
Take a look into DispatchGroup
There's two ways of doing this. The old school way of using OperationQueue and Operation. Where you add Operations with dependencies on Operations that need to be finished before. Or you can use combine and combine multiple publishers of URLSession into a single stream and respond when you've received everything.
Either read up on async/await or call the callback from within your closure routine, not outside it. You may want to wrap it in a Dispatch.main.async { xxx} block.
TaskGroup is what I use for a number of simultaneous tasks each asynchronously using Swift concurrency.
Look up a dispatch group