Ambiguous use of DB control base

I really can not understand what is wrong? I am trying to load some settings data from firebase Settings node. The same code for other nodes in other functions works, but it 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. } 
+5
source share
2 answers

Change this:

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

:

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

See also the firebase documentation section. Listening for Value Events

+11
source

You can write your call something like this:

 ref .child("Settings") .child("service_types") .observe(.value) { (snapshot: FIRDataSnapshot) in // your code } 

or

 ref .child("Settings") .child("service_types") .observe(.value, with: { snapshot in // your code }) 
+1
source

Source: https://habr.com/ru/post/1258249/


All Articles