DevPrep

All topics › Real interview tasks

Implement parallel image loading without a data race (GCD + async)

Senior PRO

Task

You have fetchImage(url:) (an async variant and a completion variant). Implement fetchImages(urls:) so images load in parallel, the result preserves the order of urls, and the code has no data race and compiles in Swift 6 mode.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store