0

次のように、pfquerytableviewcontroller でテーブル メソッドのデリゲート クエリを使用しています。

- (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;
}

問題なく動作します。最初にすべてのユーザーを選択するクエリを使用するにはどうすればよいですか?

4

1 に答える 1

0

質問を完全に理解しているかどうかわからないので、間違っている場合は修正してください。なぜこのコードを queryForTable に入れられないのでしょうか?

PFQuery *query = [FollowerRelation クエリ]; [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;

テーブルに対して正確にどのクエリを実行/返したいですか?

于 2014-08-01T05:02:29.850 に答える