Reputation: 15
dbRef.observe(.value, with: { (snapshot: FIRDataSnapshot in
for thingy in snapshot.children {
let thingyFinal = thingy as? FIRDataSnapshot
print(thingyFinal)
}})
My database structure is as follows:
->mung-37e2c: {
"users": {
"kimkardashian": "stuff",
"donaldtrump": "stuff"
},
goals: {
"goal1" : "stuff",
"goal2" : "stuff"
}
}
What I cannot wrap my head around is that the error is triggered by the first line of my code:
dbRef.observe(.value, with: { (snapshot: FIRDataSnapshot in
Since I am not force unwrapping here, why is the unwrapping error being triggered. Also, the database has not nil values.
Upvotes: 0
Views: 168
Reputation: 9945
Try changing your code to :-
FIRDatabase.database().reference().observe(.value, with: { (snapshot: FIRDataSnapshot) in
for thingy in snapshot.children {
let thingyFinal = thingy as? FIRDataSnapshot
print(thingyFinal)
}
})
Upvotes: 1