观察Firebase DB的歧义使用 [英] Ambiguous use of observe firebase DB

查看:100
本文介绍了观察Firebase DB的歧义使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的无法理解出什么问题了吗?
我正在尝试从Firebase Settings节点加载一些设置数据.其他功能中其他节点的相同代码也可以工作,但是这是模棱两可的.为什么?

I really cannot get what is wrong?
I'm trying to load some settings data from firebase Settings node. Same code for other nodes in other functions work but this one is ambiguous. Why?

var ref:FIRDatabaseReference!  //Global variable

     override func viewDidLoad() {
        super.viewDidLoad()


        self.mapView.delegate = self

            if CLLocationManager.locationServicesEnabled() {

                locationManager.delegate = self
                locationManager.desiredAccuracy = kCLLocationAccuracyBest
                locationManager.requestWhenInUseAuthorization()
                locationManager.startUpdatingLocation()

              //  monitorRegion()

            } else {

                // Alert to enable location services on iphone first
            }

            ref = FIRDatabase.database().reference(fromURL: "https://*******.firebaseio.com/")
            //The error is here
            ref.child("Settings").child("service_types").observe(.value) { (snapshot) in

            }


        // Do any additional setup after loading the view.
    }

推荐答案

更改此内容:

ref.child("Settings").child("service_types").observe(.value) { (snapshot) in

}

对此:

ref.child("Settings").child("service_types").observe(.value, with: { snapshot in

})

另请参见 firebase文档部分监听价值事件

这篇关于观察Firebase DB的歧义使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆