var username: String? = nil
self.ref.child("users").observeSingleEvent(of: .value, with: { (snapshot) in
let usersProfile = snapshot.value as? NSDictionary
let userProfile = usersProfile![userID] as? NSDictionary
username = userProfile!["username"] as! String
}) { (error) in
print(error.localizedDescription)
}
print(username)
Why is the variable username
not updated in the end?