【问题标题】:Querying for a pointer attribute using Parse使用 Parse 查询指针属性
【发布时间】:2015-08-29 17:33:39
【问题描述】:

我正在开发一个在 Parse 上使用 User 和 Request 作为类的应用程序。我的用户有 currentLocation (PFGeoPoint) 作为属性,请求有一个指针来引用拥有请求的用户 (requestor:PFUser)。所以我试图找到来自当前登录用户附近的用户的请求。

我需要做类似的事情:

let currentUserGeoPoint = PFUser.currentUser()!["currentLocation"] as! PFGeoPoint

var query = PFQuery(className:"Request")
query.whereKey("requestor.currentLocation", nearGeoPoint: currentUserGeoPoint)
query.findObjectsInBackgroundWithBlock {
      (objects, error) -> Void in
          if (error == nil) {
             self.userRequests = objects!
             self.tableView.reloadData()
          }else {
             println(error?.userInfo)
          }
}

但不幸的是,这是不可能的:

[Error]: Dot notation can only be used on objects (Code: 102, Version: 1.8.1)
Optional([code: 102, error: Dot notation can only be used on objects, temporary: 0, NSLocalizedDescription: Dot notation can only be used on objects])

有什么想法吗?

这就是我的请求类在 Parse 上的样子:

这是用户类:

【问题讨论】:

  • 错误消息中的dot notation 部分让我相信whereKey 中的requestor 不是对象,即您不能在非对象上调用currentLocation(“requestor.当前位置”)。你能检查一下吗?
  • 你也可以显示用户类吗?

标签: ios swift parse-platform


【解决方案1】:

Parse 社区this question

您可以使用 whereKey:matchesKey:inQuery: 或 whereKey:matchesQuery: 代替点符号。

【讨论】:

    猜你喜欢
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多