我有两个类叫做Followers
和Posts
。像这样:whereKey:matchesQuery:没有给出任何结果
Follower =(user , follower)
,用户和追随者都包含Pointers
。
Posts = (post, postedBy)
,这里postedBy包含Pointers
。我想要检索当前用户自己发布的帖子posted
,并且发布的帖子是当前用户所关注的用户。我想这:
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)
}
}
}
}
所以我应该怎么做到这一点呢?感谢您的时间..
像什么?对不起,初学者在这里。 –
我编辑了我的帖子..ü没有运行搜索的第一个查询任何地方,所以它没有给你任何结果...你必须在搜索搜索,像我张贴在编辑后 –
,给我随机顺序的帖子.. –