0
我正在將我的完全工作項目(Swift 2)轉換爲Swift 3.我停留在語法更改上。這是有用的功能,現在它不喜歡它,並給出了一些奇怪的建議,它不起作用。從Firebase中檢索兒童字典(Swift 3)
var productsValue = [[String:AnyObject]]()
let ref = FIRDatabase.database().reference().child("Snuses").queryOrderedByChild("Brand").queryEqualToValue(brandName)
ref.observeSingleEventOfType(.Value, withBlock: { (snapshot) in
if snapshot.exists(){
if let products = snapshot.value?.allValues as? [[String:AnyObject]]{//This is most confusing part. It suggest me so weird things
self.productsValue = products
self.productstable.reloadData()
}
}
})
我將它轉換並沒有錯誤,但它不填寫productValues
字典中值:
let ref = FIRDatabase.database().reference().child("Snuses").queryOrdered(byChild: "Brand").queryEqual(toValue: brandName)
ref.observeSingleEvent(of: .value, with: { (snapshot) in
if snapshot.exists(){
if let products = (snapshot.value as AnyObject).allValues as? [[String:AnyObject]]{
self.productsValue = products
self.productsTable.reloadData()
}
}
})
你能幫我得到這個充滿我的字典,值?
我不好,錯過了'.value' - 剛更新了我的答案 – Callam