【发布时间】:2021-02-02 13:40:20
【问题描述】:
我怎样才能得到这个 GeoFire 的价值?
错误消息:实例成员“查询”不能用于类型“GeoFire”;您的意思是改用这种类型的值吗?
let center = CLLocation(latitude: location.coordinate.latitude, longitude: location.coordinate.longitude)
let circleQuery = GeoFire.query(at: center, withRadius: 20);
circleQuery.observe(.keyEntered) { (key, location,snapshot) in
// parse the snapshot for your result.
print("Key '\(key)' entered the search area and is at location '\(location)'")
}
【问题讨论】:
-
查看原码:
let geofireRef = /* ... */; let geoFire = GeoFire(firebaseRef: geofireRef); geoFire.query(/*...*/) -
我做了这个,现在没有任何错误,但应用程序崩溃了......
-
因为空数组...(线程 1: "*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray")
-
我在你的代码中没有看到任何数组;您必须提供更多信息才能显示崩溃的确切位置。
-
var geofire = GeoFire(firebaseRef: querySnapshot!.documents[0].get("koordinaten") as!DatabaseReference)