【问题标题】:query with Pointer<_User> in Swift Parse SDK在 Swift Parse SDK 中使用 Pointer<_User> 进行查询
【发布时间】:2016-09-16 02:12:05
【问题描述】:

我有一个名为 Client 的类,而这个类有一个 Pointer<_user>。我正在尝试按照以下方式进行操作:

query.whereKey("user", equalTo:currentUser)

但是这样,我的查询中没有数据返回。

有人知道我该怎么做这个查询?

【问题讨论】:

  • 您还有更多代码要显示吗?您如何发起查询,如何处理响应。
  • 我认为您需要在 PFQuery(className: "_User") 中查询并使用您的客户表中的 includeKey

标签: ios iphone swift parse-platform


【解决方案1】:

您可能需要在您的类上设置includeKey 属性,该属性会获取相关对象,例如

var query = PFQuery(className:"Client")

// Retrieve the most recent ones
query.orderByDescending("createdAt")

// Include the user
query.includeKey("user")

来源:Parse iOS Guide

【讨论】:

    【解决方案2】:

    试试这个

    query.whereKey("user", equalTo: PFUser.currentUser()!)
    

    query.whereKey("user", equalTo: PFObject(withoutDataWithClassName: "_User", objectId: "\(PFUser.currentUser()!.objectId!)"))
    

    【讨论】:

    • 谢谢! query.whereKey("user", equalTo: PFUser.currentUser()!) 效果很好!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-26
    • 1970-01-01
    相关资源
    最近更新 更多