我创建了一个PFQuery来获取类“Albums”(512个对象)中的所有对象。
当我创建PFQuery并在其上调用findObjectsInBackgroundWithBlock
方法时,它只返回100个对象而不是512,尽管我添加了行
query.limit=1000;
我的代码:
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
}];
答案 0 :(得分:0)
试试这个 https://parse.com/questions/fetch-all-data-in-a-table-using-pfquery ..
NSMutableArray *allObjects = [NSMutableArray array];
NSUInteger limit = 0;
__block NSUInteger skip = 0;
PFQuery *query = [PFQuery queryWithClassName:@"MapInfo"];
[query setLimit: limit];
[query setSkip: skip];
[query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
if (!error) {
// The find succeeded. Add the returned objects to allObjects
[allObjects addObjectsFromArray:objects];
if (objects.count == limit) {
// There might be more objects in the table. Update the skip value and execute the query again.
skip += limit;
[query setSkip: skip]; //from here you run the query again with new offset
}
} else {
// Log details of the failure
NSLog(@"Error: %@ %@", error, [error userInfo]);
}
}];