SWIFT:如何在3维数组中存储Firebase数据?

问题描述

我正在尝试将3个Firebase数据存储在3维数组中,以便可以在带有标题的UITableView中显示它。

我需要做一些过滤。 我尝试了所有我能想到的解决方案,当然也用谷歌搜索,但找不到任何东西...

也许有人可以帮助我处理这段代码:)

谢谢!

static func chosenTeam(for user: User,completion: @escaping ([[PaymentTeam]]) -> Void) {
        
        var newItems = [PaymentTeam]()
        var members3D = [[PaymentTeam]]()

        
        let ref = Database.database().reference().child("selectedTeams").child(User.current.uid)
        let query = ref.queryOrdered(byChild: "selectedBool").queryEqual(tovalue: true)
        ref.observe(DataEventType.value,with: { (snapshot) in
            for item in (snapshot.children) {
                let planesItem = PaymentTeam(snapshot: item as! DataSnapshot)
                newItems.append(planesItem ?? PaymentTeam(memberJob: "",memberName: "No pending Payments",memberID: "",selectedBool: true,confirmedBool: false,paidBool: false,projectCreated: "",projectName: "Start your Projects") )
                }
            })
        
               let tempArray2: [PaymentTeam] = Array(Set(newItems))
               let tempArray3: [PaymentTeam] = tempArray2.filter {$0.selectedBool == true}
               var projectNames = [String]()
               
               for value in tempArray3 {
                   projectNames.append(value.projectCreated ?? "novalue")
               }
               let tempuniqueNames = Array(Set(projectNames))
               for value in tempuniqueNames {
                
                var temp4:[PaymentTeam] = tempArray3.filter {$0.projectCreated == value}
                members3D.append(temp4)
               }
               completion(members3D)
           }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)