title: Async image loading from url inside a UITableView cell - wrong image loading while scrolling
body: <p>I have a tableView that displays an image in the cell. Most of the time the correct image will be displayed, however occasionally it will display the wrong image (usually if scrolling down the tableView very quickly). I download the images asynchronously.</p>
  
  <pre><code>cell.profImg.getImgFromUrl(link: man.img, contentMode: cell.profImg.contentMode)
  </code></pre>
  
  <p>And here i do async request:</p>
  
  <pre><code>extension UIImageView {
  func getImgFromUrl(link link:String, contentMode mode: UIViewContentMode) {
      guard
          let url = NSURL(string: link)
          else {return}
      contentMode = mode
      NSURLSession.sharedSession().dataTaskWithURL(url, completionHandler: { (data, response, error) -&gt; Void in
          guard
              let httpURLResponse = response as? NSHTTPURLResponse where httpURLResponse.statusCode == 200,
              let mimeType = response?.MIMEType where mimeType.hasPrefix("image"),
              let data = data where error == nil,
              let image = UIImage(data: data)
              else { return }
          dispatch_async(dispatch_get_main_queue()) { () -&gt; Void in
              self.image = image
          }
      }).resume()
      }
  }
  </code></pre>