I have three nodes in firebase that I would like to loop through using the same loop. I\'m successfully able to loop through a single node (cookies) using this code:
<
The following code prints all three levels of snapshots. I hope this will help:
self.databaseRef.child("cookies").observeSingleEvent(of: .value, with: { (cookiesSnapshot) in
print("cookies snapshot: \(cookiesSnapshot)")
self.databaseRef.child("dessert").observeSingleEvent(of: .value, with: { (dessertSnapshot) in
print("dessert snapshot: \(dessertSnapshot)")
self.databaseRef.child("breakfast").observeSingleEvent(of: .value, with: { (breakfastSnapshot) in
print("breakfast snapshot: \(breakfastSnapshot)")
})
})
})
I can't check this, so I hope all the } and ) are at the right place. :)