我真的不知道哪里出了问题?
我正在尝试从 firebase Settings
节点加载一些设置数据。其他功能中其他节点的相同代码有效,但这个代码不明确。为什么?
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
})
关于swift - 模棱两可地使用 observe firebase DB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40057276/