首页 > 解决方案 > 使用 Swift 从 firebase 检索嵌套数据

问题描述

我如何访问嵌套的网站 url。我也不知道如何访问 Medium 部分下的 img。通过提供的图像中的代码,我可以毫无问题地访问其他信息:

我的火力基地是什么样的

我的代码是什么样的

    ref = Database.database().reference()

    ref.child("artists").queryOrderedByKey().observe(.value) { snapshot in
        var temp = [Artist]()
        for child in snapshot.children {

            if let child = child as? DataSnapshot {
                // decode json into Artist Struct
                let model = try! FirestoreDecoder().decode(Artist.self, from: child.value as! [String : Any])
                temp.append(model)

               // print(model)

            }
        }

标签: iosswiftfirebasefirebase-realtime-database

解决方案


Let ref = Database().database.refrence()

ref.child("TopNode").child("secondInerNode").observe(.value, with: {//stuff})

您将路径写入您拥有数据的位置,然后进行观察。

TopNode
   secondInerNode
      name: value;

检查文档以获取更多信息。


推荐阅读