【问题标题】:Ambiguous use of 'observe' - myQuery.observe(GFEventType)'observe' 的模糊使用 - myQuery.observe(GFEventType)
【发布时间】:2020-02-18 15:05:12
【问题描述】:

我正在尝试通过 GeoFire 查找用户,由于某种原因,此语法不适用于我....

  func findUsers () {
    guard let userLat = userDefault.value(forKey: "current_location_latitude") as? String, let userLong = userDefault.value(forKey: "current_location_longitude") as? String else {return}

    let location: CLLocation = CLLocation(latitude: CLLocationDegrees(Double(userLat)!), longitude: CLLocationDegrees(Double(userLong)!))

    myQuery = geoFire.query(at: location, withRadius: distance)

 --->  ** myQuery.observe(GFEventType.keyEntered) { (key, location) ** in
        print(key)
    }


}

给我一​​个“模糊使用'观察者'”的错误

【问题讨论】:

    标签: jquery ios swift observers geofire


    【解决方案1】:

    这对我有用:

    func findUsers () {
        guard let userLat = userDefault.value(forKey: "current_location_latitude") as? String, let userLong = userDefault.value(forKey: "current_location_longitude") as? String else {return}
    
        let location: CLLocation = CLLocation(latitude: CLLocationDegrees(Double(userLat)!), longitude: CLLocationDegrees(Double(userLong)!))
    
        myQuery = geoFire.query(at: location, withRadius: distance)
    
        myQuery.observe(.keyEntered, with: { (key, location) in
            print(key)
        })
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      相关资源
      最近更新 更多