0

I am using the delegate query for table method in my pfquerytableviewcontroller like so:

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

}

When I do a simple query like:

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

    [query orderByDescending:@"createdAt"];

    return query;
}

It works with no problem. How do I use my query that first selects all users?

1
  • Please elaborate more on what the problem is. What is happening when you run this code?
    – Jacob
    Aug 1, 2014 at 20:51

1 Answer 1

0

I'm not sure i understand the question fully, so if I'm wrong please correct me. Why can't you just put this code in queryForTable?

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;

Exactly what query do you want to accomplish/return for the table?

4
  • That is essentially what I did, but extracted out to another method. I think since there is latency on this call in the main thread, the method shuts down.
    – Atma
    Aug 1, 2014 at 14:05
  • So the issue is that the query is not executing correctly?
    – Jacob
    Aug 1, 2014 at 17:03
  • Before I switched to the pfquerytableviewcontroller, this identical query worked no problem.
    – Atma
    Aug 1, 2014 at 18:15
  • Does it crash or just take a while to load?
    – Jacob
    Aug 1, 2014 at 18:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.