swift - PFQueryTable 使用子查询不在 Swift 中返回结果

标签 swift parse-platform pfquery pftableviewcell

我有一个使用 Parse 的 Swift 项目,我正在使用 PFQueryTable 来填充带有原型(prototype)单元格的表格。下面是我的 queryForTable 部分,用于查询我感兴趣的数据。我的主要查询是针对一个名为“Friends”的类,它有一个名为 user 的指针列,指向“User”类。在“Friends”类中还有一个名为 friendId 的列,它也指向“User”

我想在“Friends”类中检索记录,其中我的 friendId 等于我的当前用户并且已批准标志为真。

一旦我有了这些记录,我将检索在过去一小时内或我设置的任何时间具有 checkInTime 的“用户”记录。现在我只是试图返回符合我的第一个条件的记录,并在我的表中显示来自“用户”类的用户名。

override func queryForTable() -> PFQuery {
    let friendsListQuery = PFQuery(className: "Friends")
    friendsListQuery.whereKey("friendId", equalTo: PFUser.currentUser()!)
    friendsListQuery.whereKey("approved", equalTo: true)


    let checkInQuery = PFUser.query()
    checkInQuery!.whereKey("objectId", matchesKey: "user", inQuery: friendsListQuery)


    return checkInQuery!

}

目前查询没有返回任何记录。有什么想法吗?

最佳答案

问题在这里

checkInQuery!.whereKey("objectId", matchesKey: "user", inQuery: friendsListQuery)

objectId 键无法与用户指针匹配。

就取决于您的 Parse 类结构的解决方案而言。 “好友”的目的是代表两个用户之间的关系吗?

关于swift - PFQueryTable 使用子查询不在 Swift 中返回结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33174689/

相关文章:

ios - MKMapView:如何复制在 Apple 的 'bounce-zoom' 应用程序中看到的 'Find my iPhone/Friends'?

ios - UIView、Swift 上的深度页面变换

swift - 无法调用没有参数 UITableViewController 的 reloadData

java - Facebook/Parse 登录行为异常 : The proxied app is not already installed

ios - 集成解析时在 Xcode 中出错

xcode - PFQuery.getObjectWithId(objectId : String) --- 'AnyObject?' is not convertible to 'String' error --- Parse sdk 1. 7.1 和 Xcode 6.3

ios - parse.com containsAllObjectsInArray 限制

objective-c - Swift 中的 UIButton 帮助

iOS + Parse Cloud Code - 更新特定用户(未登录用户)

swift - PFQuery 中的逻辑运算符错误