I want to get a value from my Firebase Database and add 10 points to it after the user clicks on a button.
my Firebase Database looks like:
usersaddclose
profile
-DiGPeQWLUkR35YjvTYmS9SxWPQo1
fullname:
pathToImage:
points: 23 (need to get this value)
username:
code below doesn't work. With the error: Could not cast value of type 'NSTaggedPointerString' (0x112b74560) to 'NSNumber' (0x1113dcd40). I'm not sure how else to structure it.
@IBAction func commentBtn(_sender: Any) {
let bef = Database.database().reference().child("users/profile/\(uid)/points")
bef.observeSingleEvent(of: .value, with: { (snapshot) in
var db = snapshot.value as! Int
db += 10
print(db)
})
}