我想使用 swift 读取 restaurant
names Burger King
, Eating Point
。
这怎么可能,谁能帮帮我,这是因为我的期末项目需要在 1 周内提交,我对这个失去了希望
ref = Database.database().reference()
ref?.child("Restaurants").observe(.childAdded, with: { (snapshot) in
let rest = snapshot.value as? String
if let actualPost = rest {
self.restList.append(actualPost)
print("list of rest ", self.restList)
self.restTableView.reloadData()
}
})
最佳答案
只需使用以下代码获取父节点名称。
ref = Database.database().reference()
ref?.child("Restaurants").observe(.childAdded, with: { (snapshot) in
let rest = snapshot.value as? String
// snapshot.key is give you parent node name
print(snapshot.key)
}
})
关于ios - 如何在不从 firebase For ios 获取值的情况下读取父节点名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50207287/