如何在pfquery tableviewcontroller中进行复合查询

时间:2014-07-31 23:30:02

标签: ios cocoa-touch parse-platform pfquery

我在pfquerytableviewcontroller中使用table方法的委托查询,如下所示:

- (PFQuery *)queryForTable {

    return [self getMyQuery];
}

- (PFQuery *) getMyQuery{
    PFQuery *query = [FollowerRelation query];
    [query whereKey:@"follower" equalTo:user];

    NSArray *foundFollowers = [query findObjects];
    NSMutableArray *followers = [[NSMutableArray alloc] init];

    for (FollowerRelation *aFollower in foundFollowers) {
        [followers addObject:aFollower.user];
    }

    PFQuery *query1 = [GAStatus query];
    [query1 whereKey:@"user" containedIn:followers];
    [query1 includeKey:@"user"];
    [query1 orderByDescending:@"createdAt"];

    return query1;

}

当我做一个简单的查询时:

- (PFQuery *)queryForTable {
    PFQuery *query = [PFQuery queryWithClassName:self.parseClassName];
    [query includeKey:@"gaUser"];
    if (self.objects.count == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }

    [query orderByDescending:@"createdAt"];

    return query;
}

没问题。如何使用首先选择所有用户的查询?

1 个答案:

答案 0 :(得分:0)

我不确定我完全理解这个问题,所以如果我错了,请纠正我。为什么不能将此代码放在queryForTable中?

PFQuery * query = [FollowerRelation查询];     [查询whereKey:@"关注者" equalTo:用户];

NSArray *foundFollowers = [query findObjects];
NSMutableArray *followers = [[NSMutableArray alloc] init];

for (FollowerRelation *aFollower in foundFollowers) {
    [followers addObject:aFollower.user];
}

PFQuery *query1 = [GAStatus query];
[query1 whereKey:@"user" containedIn:followers];
[query1 includeKey:@"user"];
[query1 orderByDescending:@"createdAt"];

return query1;

您想要为表格完成/返回什么查询?