Member-only story

How to manage a set of Async function in for — in block in Swift.

Fredric Cliver
Mar 14, 2021

--

Photo by Michał Parzuchowski on Unsplash

You might need to wait for a set of async calling to finish a final method. and In this case, let’s suppose you used the For syntax to call the parallel callings.

If you used one single async method, you can use handler. But if all method chained with together, it takes too much time.

Every call will not be executed as parallel

So you can use DispatchGroup. After every .leave() has been called as same as a count of .enter() has been called, the notify() will be called finally.

--

--

Fredric Cliver
Fredric Cliver

Written by Fredric Cliver

13+ years in the digital trenches. I decode complex tech concepts into actionable insights, focusing on AI, Software Engineering, and emerging technologies.

No responses yet