title: How to retrieve a list in Firebase database folder?
body: <p>I have a folder in my Database called "Cars", within the folder is a list of car brands, I want to retrieve all the brands and put it in a UITableView. Then when you press on a brand it will show the models of the brand. I have a trouble retrieving the list of cars at the moment. This is the screenshot of my Database and my code for the view controller.</p>
  
  <p><a href="https://i.stack.imgur.com/t5d3t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t5d3t.png" alt="enter image description here"></a></p>
  
  <pre><code>import UIKit
  import Firebase
  import FirebaseDatabase
  import SDWebImage
  
  struct carStruct {
      let cars : String!
  
  }
  
  class CarMakeViewController: UIViewController, UITableViewDataSource, UITableViewDelegate  {
  
      var cars = [carStruct]()
  
      override func viewDidLoad() {
          super.viewDidLoad()
          let ref = Database.database().reference().child("Cars")
  
          ref.observeSingleEvent(of: .value, with: { snapshot in
              print(snapshot.childrenCount)
              for rest in snapshot.children.allObjects as! [DataSnapshot] {
                  guard let value = rest.value as? Dictionary&lt;String,Any&gt; else { continue }
                  guard let  make = value["Cars"] as? String else { continue }
                  let cars = carStruct(cars: make)
                  self.cars.append(cars)
              }
  
          self.cars = self.cars.reversed(); self.tableView.reloadData()
          })
  
      }
  
      @IBOutlet weak var tableView: UITableView!
  
      func numberOfSections(in tableView: UITableView) -&gt; Int {
          return 1
      }
  
      func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
          return cars.count
      }
  
      func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
          let cell = tableView.dequeueReusableCell(withIdentifier: "cellMake")
  
          let label1 = cell?.viewWithTag(21) as! UILabel
          label1.text = cars[indexPath.row].cars
  
          return cell!
      }
  
  }
  </code></pre>