我在学生程序员生涯中思考的时间最长。我想知道
我使用 autoChildId 添加了 key 。
如何从 firebase 数据库 swift 2 获取 key ?我知道如何使用 .getKeys() 从 Android 获取
我最好的 friend Google 教我使用 allKeys。然而,我的友谊现在正处于绝望的边缘,因为我收到以下消息,我们与 .allKeys 的关系将永远失败(见下图)。哈什……
- 我需要这个来将 Firebase 数据库中的数据显示到我的 TableView 中,因为我相信这是一个空表的问题,就像我对我的项目的心意一样。没有心。
这是我的 firebase 数据库的样子:
这是我的代码:
func findPlaceToEat(){
print("inside findPlaceToEat()")
print("Plan price level")
print(planPriceLevel)
print("End of price level")
ref = FIRDatabase.database().reference()
ref.child("places_detail").child("price_level").child(planPriceLevel).observeEventType(.ChildAdded, withBlock:{
(snapshot) in
if let dictionary = snapshot.value?.allKeys! as? [String: AnyObject]{
let PlaceObj = placeObj(place_name: dictionary["place_name"] as! String, place_type: dictionary["place_type"] as! String, price_range: dictionary["price_range"] as! String, vegan_type:dictionary["vegan_type"] as! String , website: dictionary["website"] as! String)
print("Whatever")
print(PlaceObj);
//self.tableView.reloadData()
}
}, withCancelBlock: nil)
}
最佳答案
从快照中获取 key
snapshot.key
关于ios - 无法从 firebase 数据库获取 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42227064/