title: Swift - Downloading Multiple Images Asynchronously
body: <p>I currently have working code that lets me download a single image. It then puts that image in a imageview inside a collectionview cell.</p>
  
  <p>However, I want to download 2 images from 2 different URLs. Do I need to create another URLSession Task, or can I simply download 2 images with the same session?</p>
  
  <pre><code>let url = URL(string: "www.example.com/image.jpg")
  let task = URLSession.shared.dataTask(with: url!) { data, response, error in 
  guard let data = data, error == nil else { return }
  
  DispatchQueue.main.async() {
      cell.postImage.image = UIImage(data: data) 
      }
  }
  </code></pre>
  
  <p>Edit: Not sure why Leo marked my question as a duplicate. I already saw that post and it only loads a single image. My questions is in regards to the correct way of downloading multiple images smh.</p>