For some reason, the data from my FirebaseDatabase is not showing up in my TableView. I've done the "tableView.delegate and tableView.datasource = self", I've registered the "cell". I've even added tested mock arrays like "var postData: [String] = ["delivery", "fun"]" and they have showed up in my tableView. Any idea what I am doing wrong?
import UIKit
import Firebase
import FirebaseDatabase
class NewConversationViewController: UITableViewController {
var ref: DatabaseReference!
var userData = [String]()
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
ref = Database.database().reference()
ref.child("users\("name")").observeSingleEvent(of: .childAdded) { (snapshot) in
let user = snapshot.value as? String
if let actualUsers = user {
self.userData.append(actualUsers)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
}
override func tableView( tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return userData.count
}
override func tableView( tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.text = userData[indexPath.row]
return cell
}
}