我无法弄清楚为什么我的代码无法在UIlabel中显示用户的用户名?我的代码是:
@IBOutlet weak var userNameOut: UILabel!
var loggedInUser = AnyObject?.self
var databaseRef = DatabaseReference()
var storageRef = StorageReference()
let loggedInUser = Auth.auth().currentUser?.uid
databaseRef.child("user_profiles").child(loggedInUser!).observeSingleEvent(of: .value) { (snapshot) in
let value = snapshot.value as? Dictionary<String, AnyObject>
print(value?["user_profiles"] as? String ?? "")
self.userNameOut.text = value?["user_profiles"] as? String ?? ""
}
我认为问题在于获取用户。花了5个小时试图解决这个问题。