title: UITableView loading data into wrong cells
body: <p>Below I am trying to load data into a UITableView and every time the data ends up either in the wrong cell or duplicated into cells it should never had access to.  I  have cut out a lot of extra code and am still running into this problem. I think I am missing something fundamental about UITableViews.</p>
  
  <pre><code>    func setUpFeedTable() {
  
                  self.tableFeed.isScrollEnabled = true
  
                  for i in 0 ..&lt; allDictionary.count {
  
  
                      let dictionary = allDictionary[i]
  
  
                      if dictionary?["type"]! != nil {
                          let l = i
                          print("text", l)
                          self.tableFeed.cellForRow(at: IndexPath(row: l, section: 0))?.imageView?.layer.borderColor = UIColor.black.cgColor
                          self.tableFeed.cellForRow(at: IndexPath(row: l, section: 0))?.imageView?.layer.borderWidth = 1
                          self.tableFeed.cellForRow(at: IndexPath(row: l, section: 0))?.imageView?.layer.cornerRadius = 1
  
                          //self.tableFeed.cellForRow(at: IndexPath(row: i, section: 0))?.imageView?.clipsToBounds = true
                          self.editProfileButton.imageView?.contentMode = UIViewContentMode.scaleAspectFill
                          //self.tableFeed.reloadData()
                          //self.tableFeed.reloadRows(at: [IndexPath(row: l, section: 0)], with: UITableViewRowAnimation(rawValue: 0)!)
  
                          self.tableFeed.cellForRow(at: IndexPath(row: l, section: 0))?.imageView?.frame = CGRect(x: 0, y: UIScreen.main.bounds.height/2, width: 100, height: 100)
  
                          self.tableTextOverLays(i: l, type: Int((dictionary?["type"])! as! NSNumber))
  
                          //self.tableFeed.reloadRows(at: [IndexPath(row: l, section: 0)], with: UITableViewRowAnimation(rawValue: 0)!)
  
                          self.tableFeed.reloadDate()
                      }
  
                      else if (dictionary?["type_"] as! String) == "Image" {
                          print("image", i)
  
                      }
                      else {
                          print("video")
                      }
  
  
  
                  }
  
  
  
              }
  
              func tableTextOverLays(i: Int, type: Int){
                  if type == 0{
                      print("saw type 0", i)
                      self.tableFeed.cellForRow(at: IndexPath(row: i, section: 0))?.imageView?.image = #imageLiteral(resourceName: "Geo-fence-50")
                  }
  
                  else if type == 1 {
                      self.tableFeed.cellForRow(at: IndexPath(row: i, section: 0))?.imageView?.image = #imageLiteral(resourceName: "Happy-50")
                  }
  
                  else if type == 2 {
                      self.tableFeed.cellForRow(at: IndexPath(row: i, section: 0))?.imageView?.image = #imageLiteral(resourceName: "Information-50")
                  }
  
                  else if type == 3 {
                      self.tableFeed.cellForRow(at: IndexPath(row: i, section: 0))?.imageView?.image = #imageLiteral(resourceName: "Home-50")
                  }
              }
  </code></pre>
  
  <p>Update:  I have edited my code and things are working far better (so thank you!)  but I am now running into the issue of a images being place both into the first two cells and then the 4th and 5th cells.</p>
  
  <pre><code>func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
  
          if tableView == self.table {
              return users2.count
  
          }
          else {
              //print("married barry", tableFeedCount)
              return tableFeedCount
          }
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
          if tableView == self.table {
              let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath) as UITableViewCell
              cell.textLabel?.text = self.users2[indexPath.row].name
              return cell
          }
          else {
              //print("working?")
              let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath) as UITableViewCell
              let dictionary = allDictionary[indexPath.row]
  
  
              if dictionary?["type"]! != nil {
                  cell.imageView?.layer.borderColor = UIColor.black.cgColor
                  cell.layer.borderWidth = 1
                  cell.imageView?.layer.cornerRadius = 1
  
  
                  cell.imageView?.frame = CGRect(x: 0, y: UIScreen.main.bounds.height/2, width: 100, height: 100)
  
                  self.tableTextOverLays(i: indexPath.row, type: Int((dictionary?["type"])! as! NSNumber), cell: cell)
  
              }
  
              else if (dictionary?["type_"] as! String) == "Image" {
                  print("image")
  
              }
              else {
                  print("video")
              }
  
  
              return cell
          }
  
      }
  </code></pre>