title: Swift | TableView is Empty / Blank (using Custom Cell)
body: <p>My TableView is empty/ just shows the blank cells (screenshot)
  I tried it both with a TableViewController and a ViewController with a TableView - both show the same result.
  <a href="https://i.stack.imgur.com/H7qDb.png" rel="nofollow noreferrer">enter image description here</a></p>
  
  <p>So I tried to identify where excactly the problem is located and it seems that a "for-statesment" is not being read. (see the checks printed)</p>
  
  <p>Im new to coding, but this just doesn't make any sense, I have tried all the great suggestion here on stackoverflow but none seem to work
  (all outlets are connected etc. etc.)</p>
  
  <p>Ill post both variations: ViewController and the TableViewController (which both should get the same info)</p>
  
  <p><strong>TableViewController:</strong></p>
  
  <pre><code>import UIKit
  import Parse
  
  class HistoryTableViewController: UITableViewController {
  
  var zeit = [String]()
  var kosten = [String]()
  var kilometer = [String]()
  var datum = [String]()
  
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
  
      let query = PFQuery(className: "GemachteFahrten")
  
      query.whereKey("gefahreneZeit", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("kosten", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("createdAt", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("gefahreneKilometer", equalTo: (PFUser.current()?.objectId!)!)
  
      print("check1")
  
      query.findObjectsInBackground { (objects, error) in
  
          if error != nil {
  
              print("error finding user data")
  
  
          } else {
  
              print("check2")
              if let fahrtenRequests = objects {
  
                  self.zeit.removeAll()
                  self.datum.removeAll()
                  self.kosten.removeAll()
                  self.kilometer.removeAll()
  
                  print("check3")
  
  
                  for fahrtenRequest in fahrtenRequests {
  
                      print("check4")
  
                      self.zeit.append(fahrtenRequest["gefahreneZeit"] as! String!)
                      self.kosten.append(fahrtenRequest["kosten"] as! String)
                      self.datum.append(fahrtenRequest["createdAt"] as! String)
                      self.kilometer.append(fahrtenRequest["gefahreneKilometer"] as! String)
  
                      self.tableView.reloadData()
  
                      print("check5")
  
                  }
                  print("check6")
  
              }
           }
      }
  
      self.tableView.reloadData()
  }
  
  override func viewDidAppear(_ animated: Bool) {
  
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  // MARK: - Table view data source
  
  override func numberOfSections(in tableView: UITableView) -&gt; Int {
      // #warning Incomplete implementation, return the number of sections
      return 1
  }
  
  override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      // #warning Incomplete implementation, return the number of rows
      return datum.count
  }
  
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: "CellHistory", for: indexPath) as! CellHistoryViewControllerTableViewCell
  
  
              cell.durationCell.text = zeit[indexPath.row]
  
              cell.costCell.text = kosten[indexPath.row]
              cell.routeCell.text = kilometer[indexPath.row]
  
              cell.dateCell.text = datum[indexPath.row]
  
              return cell
  
  }
  </code></pre>
  
  <p>In the console it prints this:
  <a href="https://i.stack.imgur.com/2gzSu.png" rel="nofollow noreferrer">So it seems the for-statement is not read</a></p>
  
  <p>So it seem this is the problem? Or did I do something wrong somewhere else?:</p>
  
  <pre><code>print("check3")
  
  
                  for fahrtenRequest in fahrtenRequests {
  
                      print("check4")
  
                      self.zeit.append(fahrtenRequest["gefahreneZeit"] as! String!)
                      self.kosten.append(fahrtenRequest["kosten"] as! String)
                      self.datum.append(fahrtenRequest["createdAt"] as! String)
                      self.kilometer.append(fahrtenRequest["gefahreneKilometer"] as! String)
  
                      self.tableView.reloadData()
  
                      print("check5")
  
                  }
                  print("check6")
  </code></pre>
  
  <p><strong>Also here is the other variation with ViewController and added TableView:</strong></p>
  
  <pre><code>import UIKit
  import Parse
  
  class HistoryViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
  
  var zeit = [String]()
  var kosten = [String]()
  var kilometer = [String]()
  var datum = [String]()
  
  @IBOutlet weak var tableView: UITableView!
  
  override func viewDidLoad() {
      super.viewDidLoad()
  
      let query = PFQuery(className: "GemachteFahrten")
  
      query.whereKey("gefahreneZeit", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("kosten", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("createdAt", equalTo: (PFUser.current()?.objectId!)!)
  
      query.whereKey("gefahreneKilometer", equalTo: (PFUser.current()?.objectId!)!)
  
      print("check1")
  
      query.findObjectsInBackground { (objects, error) in
  
          if error != nil {
  
              print("error finding user data")
  
          } else {
  
              print("check2")
              if let fahrtenRequests = objects {
  
                  self.zeit.removeAll()
                  self.datum.removeAll()
                  self.kosten.removeAll()
                  self.kilometer.removeAll()
  
                  print("check3")
  
  
                  for fahrtenRequest in fahrtenRequests {
  
                      print("check4")
  
                      self.zeit.append(fahrtenRequest["gefahreneZeit"] as! String!)
                      self.kosten.append(fahrtenRequest["kosten"] as! String)
                      self.datum.append(fahrtenRequest["createdAt"] as! String)
                      self.kilometer.append(fahrtenRequest["gefahreneKilometer"] as! String)
  
                      self.tableView.reloadData()
  
                      print("check5")
  
                  }
                  print("check6")
  
              }
  
  
          }
  
      }
  
      self.tableView.reloadData()
     }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
  
  }
  
  
  
  internal func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      // #warning Incomplete implementation, return the number of rows
  
           return datum.count
  }
  
  
  internal func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell: CellHistoryViewControllerTableViewCell = tableView.dequeueReusableCell(withIdentifier: "CellHistory", for: indexPath) as! CellHistoryViewControllerTableViewCell
  
  
      cell.durationCell.text = zeit[indexPath.row]
  
      cell.costCell.text = kosten[indexPath.row]
      cell.routeCell.text = kilometer[indexPath.row]
  
      cell.dateCell.text = datum[indexPath.row]
  
      return cell
     }
  </code></pre>
  
  <p><strong>Also here is the Custom-Cell Code:</strong></p>
  
  <pre><code>import UIKit
  
  class CellHistoryViewControllerTableViewCell: UITableViewCell {
  
  
  @IBOutlet weak var dateCell: UILabel!
  
  @IBOutlet weak var durationCell: UILabel!
  
  @IBOutlet weak var costCell: UILabel!
  
  @IBOutlet weak var routeCell: UILabel!
  
  override func awakeFromNib() {
      super.awakeFromNib()
      // Initialization code
  
  }
  
  override func setSelected(_ selected: Bool, animated: Bool) {
      super.setSelected(selected, animated: animated)
  
      // Configure the view for the selected state
   }
  }
  </code></pre>
  
  <p>I really hope somebody recognizes the problem, if you need more info or screenshots just tell me :)</p>
  
  <p>Again THANKS for your help and time :)</p>