I created the function above to check if a user exists on Firebase database:
func userExists(userUid: String) -> Bool {
var userExists: Bool = false
DBRef.child("users").child(userUid).observeSingleEventOfType(.Value, withBlock: { (snapshot: FIRDataSnapshot) in
if snapshot.exists(){
userExists = true
}else{
userExists = false
}
})
return userExists
}
The problem is that the userExists function always returns "false", even if the userExists variable is setted as true inside the withBlock. Any help, please? Thanks!
Aucun commentaire:
Enregistrer un commentaire