0
firebaseリアルタイムデータベースからデータを取得しようとしていましたが、運が悪いです。firebaseリアルタイムデータベースからのデータの取得IOS Swift
userprofileデータを入力することができる4つのテキストフィールドがあり、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)
}
}
CHECK THIS-で
セーブデータ:http://stackoverflow.com/質問/ 37759614/firebase-retrieving-data-in-swift –