How do I limit the number of parse results returned. I tried this method like parse doc says but it still returns all objects ~78. Help please.
- (PFQuery *)queryForTable {
PFUser *currentUser = [PFUser currentUser];
PFQuery *query = [PFQuery queryWithClassName:@"posts"];
[query whereKey:@"school_ID" equalTo:currentUser[@"school_ID"]];
// If no objects are loaded in memory, we look to the cache first to fill the table
// and then subsequently do a query against the network.
if ([self.objects count] == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:@"createdAt"];
query.limit = 5;
return query;
}
If your trying to limit how many objects are fetched then you can set a limit to your query. However, PQTVC uses objectPerPage. So If you trying to limit the number of fetched results you will have to set a limit on the query itself otherwise PFQTVC will override your limit value with pagination enabled
So. I think based off your question you simply want to limit the number of results displayed in the PFQTVC. That's what objectsPerPage is for. This by default is set to 100.
An example:
-(id)initWithCoder:(NSCoder *)aCoder {
self.paginationEnabled = NO;
self.objectsPerPage = 5;
}
EDIT
I just reread your question but still answered it indirectly, sorry typing from iPhone and autocorrect is kicking my butt. PFQTVC overrides limit requests when pagination is enabled. Set paginationEnabled to NO in your init method and your query.limit = 5; request in (PFQuery) queryForTable will function properly