Firebase Database
driver1 Main page
toyota car details
FInal Output
So the problem is that driver1 has 2 cars. how can i make the tableView show for toyota car information and mazda car information.
I was able to show driver 1's car list by this code:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "driverRequestCell", for: indexPath)
if let email = Auth.auth().currentUser?.email {
Database.database().reference().child("Driver").queryOrdered(byChild: "email").queryEqual(toValue: email).observe(.childAdded, with: { (snapshot) in
let snapshot = self.driverRequests[indexPath.row]
if let driverRequestDictionary = snapshot.value as? [String:AnyObject] {
if let typeOfCar = driverRequestDictionary["car"] as? String {
cell.textLabel?.text = typeOfCar
}
}
})
}
return cell
}
So my current code for didSelectRowAt is:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let snapshot = driverRequests[indexPath.row]
performSegue(withIdentifier: "carDetailsSegue", sender: snapshot)
}
I think it has something to do with the snapshot, but I can't figure it out. Need help from the pro's