gpt4 book ai didi

ios - 其中 key :matchesQuery: is not giving any result

转载 作者:行者123 更新时间:2023-11-30 14:06:52 27 4
gpt4 key购买 nike

我有两个名为 FollowersPosts 的类。像这样的东西:

Follower =(user , follower) ,user 和 follower 都包含指针

Posts = (post, postsBy),这里postedBy包含指针。我想检索当前用户本身发布的帖子以及当前用户关注的用户发布的帖子。我正在尝试这个:

func loadData() {

var queryFollowers:PFQuery = PFQuery(className: "Followers")
queryFollowers.whereKey("follower", equalTo: PFUser.currentUser()!)
var postQuery:PFQuery = PFQuery(className: "Posts")
postQuery.whereKey("postedBy", matchesQuery: queryFollowers)

var postQueryCurrentUser:PFQuery = PFQuery(className: "Posts")
postQueryCurrentUser.whereKey("postedBy", equalTo: PFUser.currentUser()!)
var compoundQuery = PFQuery.orQueryWithSubqueries([postQuery, postQueryCurrentUser])
compoundQuery.findObjectsInBackgroundWithBlock { (objects, error) -> Void in

if let objects = objects {

for object in objects {

self.data.addObject(object)
println(self.data)

}

}

}
}

那么我应该怎么做才能实现它呢?感谢您的宝贵时间..

最佳答案

又是我。再说一遍,我不是 iOS 开发人员,我是 Android 开发人员,但我熟悉 Parse API。您应该阅读有关复合查询的 Parse iOS 开发人员指南。

再创建 2 个查询,因此总数为 4:

  1. 查找所有关注者 (queryFollowers)
  2. 查找关注者的所有帖子 (postQuery)
  3. 查找当前用户的所有帖子
  4. 通过复合查询组合查询 2 和 3

    func loadData() {

    var queryFollowers:PFQuery = PFQuery(className: "Followers")
    queryFollowers.whereKey("follower", equalTo: PFUser.currentUser()!)
    var postQuery:PFQuery = PFQuery(className: "Posts")
    postQuery.whereKey("postedBy", matchesQuery: queryFollowers)
    var postQueryCurrentUser:PFQuery = PFQuery(className: "Posts")
    postQueryCurrentUser.whereKey("postedBy", equalTo:PFUser.currentUser())
    PFQuery *compoundQuery = [PFQuery orQueryWithSubqueries:@[postQuery,postQueryCurrentUser]];

    [compoundQuery findObjectsInBackgroundWithBlock:^(NSArray *结果,NSError *错误) {
    //结果包含当前用户和关注者的帖子
    }];

我不确定语法。但我希望你能明白。另外,请考虑接受我对您昨天的问题的回答。 =)

关于ios - 其中 key :matchesQuery: is not giving any result,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32264534/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com