This is my structure in the Firebase Realtime database:
I want to get for all products the name.
Here's what I tried:
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)
}
But this gives my following error:
Type 'Any' has no subscript members.
I know I would need to cast the snapshot somehow but couldn't figure out how to do this. using Swift 3.