Firebase Retrieving Data in Swift

后端 未结 6 2183
长情又很酷
长情又很酷 2020-12-14 12:35

I\'m trying to retrieve specific data from just the currently logged in user. My data in my database looks like this:

6条回答
  •  没有蜡笔的小新
    2020-12-14 12:57

    Swift 4

    let ref = Database.database().reference(withPath: "user")
        ref.observeSingleEvent(of: .value, with: { snapshot in
    
            if !snapshot.exists() { return }
    
            print(snapshot) // Its print all values including Snap (User)
    
            print(snapshot.value!)
    
            let username = snapshot.childSnapshot(forPath: "full_name").value
            print(username!)
    
        })
    

提交回复
热议问题