I have a lite problem, I cannot recover the carte value in my database. when i get there for username. But the path is good.
My code :
override func viewDidLoad() {
super.viewDidLoad()
loadCarte()
}
func loadCarte(){
var ref: DatabaseReference!
ref = Database.database().reference()
let userID = Auth.auth().currentUser?.uid
ref.child("users").child(userID!).observeSingleEvent(of: .value, with: { (snapshot) in
// Get user value
let value = snapshot.value as? NSDictionary
let Carte = value?["carte"] as? String ?? ""
self.carteButton.setTitle(Carte + " cartes", for: .normal)
// ...
}) { (error) in
print(error.localizedDescription)
}
}
I manage to recover other values but not that one, can that come from the fact that its being an Integer?
Thank's in Advance
EDIT : my Json structure of a User Type under users > userID
{
"carte" : 10,
"email" : "[email protected]",
"username" : "vicro87000"
}