title: First TableView cells are not dequeuing properly
body: <p>I'm working on the app, which loads flags to a class using <a href="https://www.countryflags.io/" rel="nofollow noreferrer">https://www.countryflags.io/</a> API. I am loading a flag when initializing the object using Alamofire get request.
  The problem is that the first few TableView cells that are dequeued when starting the app are loaded without flags. 
  <p><a href="https://giphy.com/gifs/gfNAfTm4utuehmapnV" rel="nofollow noreferrer">But when I scroll back after scrolling down, they load perfectly.</a></p></p>
  
  <p>I thought that it is happening because the request is not processed quickly enough and the first flags are not ready to load before the start of dequeuing cells. But I have no idea how to setup something inside the getFlag() method to help me reload TableView data upon completion or delay dequeuing to the point when all flags are loaded.</p>
  
  <p><strong>Country class with getflag() method</strong></p>
  
  <pre><code>import UIKit
  import Alamofire
  
  final class Country {
      let name: String
      let code: String
      var flag: UIImage?
      var info: String?
  
      init(name: String, code: String, flag: UIImage? = nil, info: String? = nil) {
          self.name = name
          self.code = code
          if flag == nil {
              getFlag()
          } else {
              self.flag = flag
          }
          self.info = info
      }
  
      func getFlag() {
          let countryFlagsURL = "https://www.countryflags.io/\(code.lowercased())/shiny/64.png"
  
          Alamofire.request(countryFlagsURL).responseData { response in
              if response.result.isSuccess {
                  if let data = response.data {
                      self.flag = UIImage(data: data)
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>cellForRowAt method</strong></p>
  
  <pre><code>override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let country = countries[indexPath.row]
          let cell = tableView.dequeueReusableCell(withIdentifier: "Country", for: indexPath)
  
          cell.textLabel?.text = country.name
          if let flag = country.flag {
              cell.imageView?.image = flag
          } else {
              cell.imageView?.image = .none
          }
  
          return cell
      }
  </code></pre>