Daily iOS
Concurrency

Combining async work

When a screen appears you call three APIs in parallel, profile, feed, and notifications, and you have to render the UI once when all of them finish. How would you build that with GCD?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Create a DispatchGroup, enter before each request, leave when its response arrives, and combine the three in notify(queue: .main) to render. Don't block with wait(), and collect results in a spot protected by a serial queue or a lock.

Share a question