fellowProgrammer
fellowProgrammer

Reputation: 327

how to receive / update data when it changes (Firebase) in swift

I have some data stored on firebase and when somebody adds to my data, through my app I want to receive and update my data. I looked at the google docs and it said to something like this...

 databaseRef.child("Leaderboard").queryOrderedByKey().observe(.childChanged, with: {
        snapshot in 

let value = snapshot.value as? NSDictionary
// put data into variables
let playerName = value?["playerName"] as! String?


 }

But for some reason it returns nil, I know I have my hierarchy right. Why is it returning nil?

Upvotes: 0

Views: 755

Answers (1)

J. Sue
J. Sue

Reputation: 79

let playerName: String = value!["playerName"] as? String

Upvotes: 1

Related Questions