To greatly simplify the question, say I have a Swift array consisting of three image URLs that I would like to download like so:
let urls:[String] = [
"http://acme.com/one.jpeg",
"http://acme.com/two.jpeg",
"http://acme.com/three.jpeg",
]
for url in urls {
downloadImage(url)
}
print("all images downloaded.")
What if I would like to download all of the files in parallel? After reading about Grand Central Dispatch (GCD) and async programming in Swift I'm still unsure how to solve that "problem". I do not want to modify the array, all I want to achieve is parallel execution of downloadImage(url)
tasks.
Thanks in advance.