在Swift中动态更改Firebase参考查找

时间:2017-01-09 17:59:12

标签: ios swift firebase firebase-realtime-database

如果我有以下初始Firebase查找

,我遇到了问题
let ref = FIRDatabase.database().reference(withPath: "Schedule").queryOrdered(byChild: "active").queryEqual(toValue : true)

ref.observe(.value, with:{ (snapshot) in

    for child in snapshot.children {
        print("\((child as! FIRDataSnapshot).value)")
        //To get week you need to access key
        print("\((child as! FIRDataSnapshot).key)")
    }
})

首次通过viewDidLoad在视图控制器swift文件中加载视图时执行的操作;现在用户决定从活动用户那里获得,如上面的代码所示:

FIRDatabase.database().reference(withPath: "Schedule").queryOrdered(byChild: "active").queryEqual(toValue : true)

并且只想根据下拉菜单中的选项禁用非活动项目,如何根据下拉菜单中的选择自动更新视图!?

0 个答案:

没有答案