【问题标题】:Parse Location of other User (swift)解析其他用户的位置(swift)
【发布时间】:2016-07-16 16:10:09
【问题描述】:

我正在尝试使用解析构建一个应用程序,我可以在其中查看其他用户的位置 - 我知道我朋友的用户名,我想获取他最后保存的位置 (GeoPoint)。该文档对我没有帮助:https://www.parse.com/docs/ios/guide#queries

你能给我示例代码,当我知道他的用户名时,如何从解析中获取该用户的 GeoPoint?

谢谢!

【问题讨论】:

  • 我假设 Geopoint 存储在您朋友的用户记录中?

标签: ios swift parse-platform geolocation


【解决方案1】:

您最好为用户执行查询,然后如果用户的用户名等于您想要的字符串,您可以通过位置键获取他们的位置值。

类似这样的东西......但玩弄它。

let query = PFUser.query()

query.whereKey("Username", equalTo:"TheUsernameYouWantToGetLocationOf")

query.findObjectsInBackgroundWithBlock { (objects:[AnyObject]!, error:NSError!) -> Void in

     if error != nil {
      //print error
     }

    for object in objects  {

       if let geoPoint = object["GeoPoint"] as? PFGeoPoint {

       //then convert to cllocation here...

      }
    }


})

【讨论】:

  • 非常感谢 Echizzle!
猜你喜欢
  • 2016-10-31
  • 2011-01-17
  • 1970-01-01
  • 2015-09-23
  • 2023-03-09
  • 1970-01-01
  • 2016-10-31
  • 1970-01-01
  • 2020-04-12
相关资源
最近更新 更多