0
我使用GeoFire搜索给定的半径,用户可以在我的应用程序中设置并存储在FireBase上。当页面加载时,在运行GeoFire查询之前,我从Firebase获取半径。但是,当我运行下面的代码时,出现以下错误:由于未捕获的异常'NSInvalidArgumentException'导致终止应用程序,原因:'精度必须小于23!'如何正确使用GeoFire存储的搜索半径?
从一些战略性地放置的打印语句开始,看起来searchRadius在GeoFire查询运行时返回0,这让我怀疑异步加载正在发挥作用。
我的问题是,我得到这个错误是由于我的searchRadius为0,如果是的话,如何确保获取我用户搜索半径的FireBase块在我的GeoFire查询之前运行?
self.ref.childByAppendingPath("users/\(self.ref.authData.uid)/searchRadius").observeEventType(.Value, withBlock: { snapshot in
self.searchRadius = snapshot.value as! Double
})
let center = CLLocation(latitude: 37.331469, longitude: -122.029825)
let circleQuery = geoFire.queryAtLocation(center, withRadius: self.searchRadius)
circleQuery.observeEventType(GFEventTypeKeyEntered, withBlock: { (key: String!, location: CLLocation!) in
//Do code for each result returned
}) //End GeoFire query
谢谢!你的解释非常感谢。 –