【发布时间】:2023-04-03 05:28:01
【问题描述】:
我一直在尝试从 firebase 实时数据库中检索数据,但没有任何运气。
我有一个 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)
}
}
【问题讨论】:
标签: ios firebase swift3 firebase-realtime-database