Como remover um identificador GeoFire para a seguinte observação no Swift?
Esta é uma pergunta para Swift, Firebase e Geofire.
Gostaria de saber como remover um identificador do GeoFire para o seguinte observador no Swift.
locationsEnd!.query(at: location, withRadius: 16.0).observe(GFEventType.init(rawValue: 0)!, with: {(key, location) in
O seguinte funciona bem (em viewDidDisappear):
locationsEnd?.firebaseRef.removeAllObservers()
No entanto, com o handle, isso não ocorre:
var locationHandle: UInt = 0
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
//following does not work:
locationsEnd?.firebaseRef.removeObserver(withHandle: locationHandle)
}
func aroundMe(_ location: CLLocation){
locationHandle = locationsEnd!.query(at: location, withRadius: 16.0).observe(GFEventType.init(rawValue: 0)!, with: {(key, location) in
//etc
})
}
Eu tentei o locationHandle da seguinte maneira, sem sucesso:
var locationHandle = FirebaseHandle()
var locationHandle: FirebaseHandle = 0
var locationHandle: UInt!
var locationHandle: UInt = 0
var locationHandle = FIRDatabaseHandle()
var locationHandle: FirebaseHandle = 0
Qualquer sugestão seria ótima, como mencionado, eu posso remover todos os observadores, mas em outros lugares eu preciso remover uma alça.