【发布时间】:2017-01-08 02:30:24
【问题描述】:
您好,我有这种 firebase 数据库结构:
我需要从数据库中检索特定数据:Shane/DatiUtente/Password 并将其添加到字符串 var 中
请有人告诉我怎么可能。
对不起,我的英语不好,我是意大利人:)
【问题讨论】:
标签: ios swift firebase firebase-realtime-database
您好,我有这种 firebase 数据库结构:
我需要从数据库中检索特定数据:Shane/DatiUtente/Password 并将其添加到字符串 var 中
请有人告诉我怎么可能。
对不起,我的英语不好,我是意大利人:)
【问题讨论】:
标签: ios swift firebase firebase-realtime-database
您将需要解析数据库并检索所需的值。应该是这样的:
//At the top of your class set an empty variable like this:
var pass = String()
//Say for example you want to display that password to a label on your storyboard
@IBOutlet weak var passLbl: UILabel!
//Inside your viewDidLoad function you would want to add this:
DBRef.child("Shane").child("DatiUtente").child("Password").observeSingleEvent(of: .value, with: { (snaps) in
if let dictionary = snaps.value as? [String: AnyObject] {
self.passLbl.text = dictionary["pass"] as? String }
// 如果你想要它到你所要求的字符串 将 self.passLbl.text 替换为您在顶部创建的空传递变量。
【讨论】: