Search code examples
iosuitableviewparse-platformpfquery

PFQuery orSubQuery for PFQueryTableViewController not working


I had a table view working off of a compound query, and I updated Parse and now it seems to not work anymore. I'm not sure if it's the Parse update, but here's the situation:

The query is as follows (in the queryForTable method (which is called) of the PFQueryTableViewController):

 self.parseClassName = @"Event";

PFQuery *attendeeQuery = [PFQuery queryWithClassName:self.parseClassName];
PFQuery *organizerQuery = [PFQuery queryWithClassName:self.parseClassName];    

[attendeeQuery whereKey:@"attendees" containsAllObjectsInArray:[NSArray arrayWithObjects:[PFUser currentUser], nil]];
[organizerQuery whereKey:@"organizer" equalTo:[PFUser currentUser]];

PFQuery *query = [PFQuery orQueryWithSubqueries:@[organizerQuery, attendeeQuery]];
[query includeKey:@"organizer"];
[query whereKey:@"isVisible" equalTo:[NSNumber numberWithBool:YES]];
[query orderByAscending:@"time"];

return query;

When I run this query, objectsDidLoad never gets called and my table view hangs in the loading state. Help please!


Solution

  • The solution has to do with the one line I didn't include above. I had this:

    if ([self.objects count] == 0) {
        query.cachePolicy = kPFCachePolicyCacheThenNetwork;
    }
    

    and it turns out in the most current Parse SDK and iOS SDK, cachePolicy is broken, so one must use kPFCachePolicyIgnoreCache to get results when using a where ContainedIn clause.

    Source:

    https://developers.facebook.com/bugs/717037238403238/