In my UIViewController I am trying to query my parse server, but I keep getting a return of 0 for it, though I know 100% that this class does have objects in it. Any thoughts?
PFQuery *query = [PFQuery queryWithClassName:@"General"];
int i;
for (i = 0; i < [follows count]; i++) {
[query whereKey:@"Session" containedIn:follows];
}
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
[query orderByDescending:@"createdAt"];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
// it never gets here...
NSLog(@"OBJECTS%@", objects);
if (!error) {
NSLog(@"Successfully retrieved %lu objects.", (unsigned long)objects.count);
for (PFObject *object in objects) {
NSLog(@"%@", object.objectId);
}
// [self gotoMain];
} else {
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];
It tells me there is no error that it successfully retrieved 0 objects in my console.
As other already suggested, I would first do the simplest query:
If it is executed without error, returns 0 objects, and the dashboard shows that there are objects that should be returned, the class name must be wrong. So please double check the class name, e.g. the spelling.
If objects are returned, your filter must be wrong. Your
foris wrong for two reasons anywhere:1) The for loop is executed
follows.count- times, but it executes always the same instruction, sinceindexis not used. I guess that you wanted to write (but this is also wrong)2) This is wrong because you can only have a single filter
whereKey:containedIn:. As has been mentioned by DevKyle, this single filter is overwrittenfollows.count-1- times, and only the last filter is used.I guess you wanted to have something like a logical OR of the individual filters. If so, you had to flatten you array, i.e. make a single array
NSArray *flattenedFollowsof all the elements infollows[i], see here and set then a single filterEDIT:
One last idea: If your query is correct (besides of the for loop) and no object is returned anyway, it might be that you don't have the right to access them. So, please, check that the ACL field of these records has the correct access rights.