I need to get current child (AutoID) from Firebase by clicking TableViewCell. I have cells with names, and I need to get ID from current name (cell) and passing to another view controller where will be displayed more details for that person. So, I'm new in swift and I want to know how to get the ID? This is in my VC1 ->
'''
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let selectedGuest = guestsList[indexPath.row]
let controller = self.storyboard?.instantiateViewController(identifier:
"GuestDetail") as! GuestDetailsViewController
controller.guestUser = selectedGuest
self.present(controller, animated: true, completion: nil)
}
//THIS IS MY VC 2
func showGuestDetails(){
ref = Database.database().reference().child("userInfo").child(uid!).child("guests")
ref.queryOrderedByKey().observeSingleEvent(of: .value) { (snapshot) in
if snapshot.childrenCount>0{
self.guestDetail.removeAll()
for guests in snapshot.children.allObjects as![DataSnapshot]{
let guestObject = guests.value as? [String: AnyObject]
let name = guestObject?["guestName"]
let familyName = guestObject?["guestFamilyName"]
let phone = guestObject?["guestPhoneNumber"]
guard let email = guestObject?["guestEmail"] as? String,
email != self.guestUser?.guestEmail else {
continue
}
let guest = GuestModel(guestName: name as? String, guestFamilyName: familyName as! String, guestPhoneNumber: phone as? String, guestEmail: email as? String)
self.phoneNoLabel.text = guest.guestPhoneNumber
self.emailLabel.text = guest.guestEmail
}
}
}
self.nameLabel.text = guestUser!.guestName
}
'''