加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – 使用observe firebase DB的模糊不清

发布时间:2020-12-14 04:52:07 所属栏目:百科 来源:网络整理
导读:我真的不能得到什么问题? 我正在尝试从firebase设置节点加载一些设置数据.其他函数中其他节点的相同代码可以正常工作,但这个代码不明确.为什么? var ref:FIRDatabaseReference! //Global variable override func viewDidLoad() { super.viewDidLoad() self
我真的不能得到什么问题?
我正在尝试从firebase设置节点加载一些设置数据.其他函数中其他节点的相同代码可以正常工作,但这个代码不明确.为什么?

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 documentation section Listen for value events

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读