Чтобы получить только названия ресторанов, используйте код ниже.
dbReference = Database.database().reference()
dbReference?.child("Restaurants").observeSingleEvent(of: .value, with: {(snapshot) in
for rest in snapshot.children.allObjects as! [DataSnapshot] {
print("Restaurant Name:\(rest.key)")
}
})
И для передачи всех данных с помощью StoryboardId используйте код ниже.
dbReference = Database.database().reference()
dbReference?.child("Restaurants").observeSingleEvent(of: .value, with: {(snapshot) in
for rest in snapshot.children.allObjects as! [DataSnapshot] {
print("Restaurant Data:\(rest)")
}
})
Поместите это в свой
И объявите переменную данных в destinationController, как показано ниже:
var data = [DataSnapshot]()
Вы должны выполнить переход от didselectRow. Вот так.
performSegue(withIdentifier: "segue", sender: self)
И вы можете передать данные выбранного элемента из функции ниже.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let index = CategorytableView.indexPathForSelectedRow
let indexNumber = index?.row
print(indexNumber!)
let VC = segue.destination as! DestinationVC
VC.data = [rest] . //You can pass here entire data of selected row.
}