1 пользователь с 2 базами данных firebase - PullRequest
0 голосов
/ 24 сентября 2018

sample image

Здравствуйте, я пытаюсь выяснить, как показать 2 автомобиля одного и того же пользователя в табличном представлении.Это возможно?

   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

            if let driverRequestDictionary = snapshot.value as? [String:AnyObject] {
                if let typeOfCar = driverRequestDictionary["car"] as? String {

                    cell.textLabel?.text = typeOfCar

                }
            }
        })
    }
    return cell

}

1 Ответ

0 голосов
/ 25 сентября 2018
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

        //just add this line
        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

}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...