0
我一直在嘗試一段時間從Firebase實時數據庫檢索數據,但沒有任何運氣。從firebase實時數據庫檢索數據IOS Swift
我有一個4文本框,您可以在其中鍵入userprofile數據,然後使用user.uid將它存儲在firebase實時數據庫中,但我不知道如何將信息恢復回標籤,例如。
以下是我如何存儲數據的代碼。關於如何檢索數據的任何想法?謝謝你的幫助。
@IBAction func saveAction(_ sender: Any) {
if favTeamTextfield != nil && usernameTextfield != nil && fullNameTextfield != nil && phoneNumberTextfield != nil
{
//Post data to firebase
ref?.child("Users").child((user?.uid)!).setValue(["Full Name": fullNameTextfield.text, "Username": usernameTextfield.text, "Phone Number": phoneNumberTextfield.text, "Favorite Soccer Team": favTeamTextfield.text])
// dismiss the page
presentingViewController?.dismiss(animated: true, completion: nil)
}
else
{
let alertController = UIAlertController(title: "Oops!", message: "Please enter a username to save!", preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
alertController.addAction(defaultAction)
self.present(alertController, animated: true, completion: nil)
}
}
檢查這 - 保存數據:http://stackoverflow.com/問題/ 37759614/firebase-retrieval-data-in-swift –