2

I've created a PFQuery to fetch all the objects in class "Albums" (512 objects).

When I'm creating a PFQuery and calling findObjectsInBackgroundWithBlock method on it, it returns just 100 objects instead of 512, although I added the line

query.limit=1000;

My code:

PFQuery *query=[PFQuery queryWithClassName:@"Albums"];
query.limit=1000;

[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
    if (error) {
        NSLog(@"Error: %@",[error description]);
    }
    NSLog(@"%lu",objects.count); //print - 100
    self.albums=objects;
    NSLog(@"%ld",(long)self.supermarkets.count); //print - 100
}];

Thank you very much!!!

Wain
  • 118,658
  • 15
  • 128
  • 151
Yhper
  • 183
  • 2
  • 14
  • try using the API console in your dashboard and see how many results do you have – Dani Pralea Jan 05 '16 at 09:15
  • @DanutPralea What is API console? for iOS? – Yhper Jan 05 '16 at 09:20
  • it's on the web, not in iOS. go to parse.com, select your app, Core, API Console – Dani Pralea Jan 05 '16 at 09:46
  • @DanutPralea Checked it, on the API Console I get all the objects (512), but on xcode I don't. – Yhper Jan 05 '16 at 10:35
  • hmm, not sure what to say. make sure you build the query correctly (maybe there's some other setting on the request, or on the entire PFQuery class? - that needs to be set in order to bypass their 100 limit). Also, try first calling findObjectsCount or whatever the method is called. – Dani Pralea Jan 06 '16 at 08:22
  • @DanutPralea I found the problem, that was because I tried to fetch from more than one class. But I still don't know how to solve it. Please help me: http://stackoverflow.com/questions/34628904/parse-returns-100-after-trying-to-fetch-from-more-than-one-class-ios – Yhper Jan 06 '16 at 08:51

1 Answers1

1

According to Parse doc, there seem to be some limitations to fetch objects from Parse. Note that the default limit of 100 and maximum limit of 1000 apply to the inner query as well, so with large data sets you may need to construct queries carefully to get the desired behaviour. You will have to query again and again until you reach the total count.

Or one thing you can try here is to use cache policy for your query like below:

PFQuery *query=[PFQuery queryWithClassName:@"Albums"];
query.limit=1000;
// use cachepolicy
query.cachePolicy = kPFCachePolicyNetworkOnly;

[query findObjectsInBackgroundWithBlock:^(NSArray * _Nullable objects, NSError * _Nullable error) {
    if (error) {
        NSLog(@"Error: %@",[error description]);
    }
    NSLog(@"%lu",objects.count); //print - 100
    self.albums=objects;
    NSLog(@"%ld",(long)self.supermarkets.count); //print - 100
}];
SanitLee
  • 1,253
  • 1
  • 12
  • 29
  • I found the problem, that was because I tried to fetch from more than one class. But I still don't know how to solve it. Please help me: http://stackoverflow.com/questions/34628904/parse-returns-100-after-trying-to-fetch-from-more-than-one-class-ios – Yhper Jan 06 '16 at 08:50
  • @Yhper I see but let's focus on this question for now. What if you use cache policy for your query? Let me know if that helps. – SanitLee Jan 06 '16 at 10:59
  • but, i think the limitation is good. Its very sad that no one is providing a workaround. Why doesn;t anyone ever mention this while we are getting started with Parse. It seems we should provide some kind of logic and loops to fetch enogh objects. But, unfortunately, some people are mentioning that the limit is 1000 and others are saying it's 100. its a trick. – nyxee Jul 31 '17 at 18:08