【问题标题】:Retrive specific data from firebase in Swift从 Swift 中的 firebase 中检索特定数据
【发布时间】:2017-01-08 02:30:24
【问题描述】:

您好,我有这种 firebase 数据库结构:

我需要从数据库中检索特定数据:Shane/DatiUtente/Password 并将其添加到字符串 var 中

请有人告诉我怎么可能。

对不起,我的英语不好,我是意大利人:)

【问题讨论】:

    标签: ios swift firebase firebase-realtime-database


    【解决方案1】:

    您将需要解析数据库并检索所需的值。应该是这样的:

     //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 替换为您在顶部创建的空传递变量。

    【讨论】:

    • 谢谢我用类似的方法解决了这个问题,你帮了我很多,再次感谢:)
    猜你喜欢
    • 2018-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-28
    • 1970-01-01
    • 2023-04-05
    相关资源
    最近更新 更多