【发布时间】:2017-04-09 18:51:11
【问题描述】:
这是我在 Firebase 实时数据库中的结构:
我想获得所有产品的名称。
这是我尝试过的:
database.child("customerID").child("productTopSeller").observe(FIRDataEventType.value, with: { (snapshot) in
for childSnap in snapshot.children.allObjects {
let product = childSnap as! FIRDataSnapshot
print(product.value?["name"] as? String ?? "")
}
}) { (error) in
print(error.localizedDescription)
}
但这给了我以下错误:
Type 'Any' has no subscript members.
我知道我需要以某种方式投射快照,但不知道该怎么做。使用 Swift 3。
【问题讨论】:
-
你试过用谷歌搜索error吗?
标签: ios swift firebase firebase-realtime-database