我遇到了GeoFire的问题。
首先,根据Geofire github页面上的文档,我无法安装cocoapod。搜索之后,我发现设置podfile的正确方法是:
pod 'GeoFire', :git => 'https://github.com/firebase/geofire-objc.git'
不确定是否有任何代码无法正常工作,但以下情况不起作用:
if let geoFire = GeoFire(firebaseRef: self.firebaseRef) {
//this is an exact match to an item in the database, there are others nearby as well
let center = CLLocation(latitude: 40.72946918822954, longitude: -73.9883231047775)
guard let circleQuery = geoFire.query(at: center, withRadius: 5) else {
return
}
var results = [String]()
circleQuery.observe(.keyEntered, with: { (key, location) in
if let result = key {
results.append(result)
}
})
circleQuery.observeReady({
print("ALL ARE LOADED: \(results)")
circleQuery.removeAllObservers()
})
以下代码没有结果。知道为什么吗?