ios - PFQuery 只返回 100

标签 ios parse-platform pfquery

我认为 PFQuery 应该有 1000 个的限制,但我有一个问题,它使用这段代码只返回 100 个对象:

- (id)initWithCoder:(NSCoder *)aDecoder
{
    NSLog(@"initwithcoder");
    self = [super initWithCoder:aDecoder];
    if (self) {
        NSLog(@"self");
        // The className to query on
        self.parseClassName = @"Directory";

        // Whether the built-in pull-to-refresh is enabled
        self.pullToRefreshEnabled = YES;

        // Whether the built-in pagination is enabled
        self.paginationEnabled = NO;

        // The number of objects to show per page
        self.objectsPerPage = 0;


    }
    return self;
}
- (PFQuery *)queryForTable {
    NSLog(@"QUERY");
    PFQuery *query = [PFQuery queryWithClassName:@"Directory"];
    // 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;
    }
    NSLog(@"Count%lu", self.objects.count);
    [query orderByAscending:@"title"];

    return query;
}

我试过使用“0”以及“500”或“1000”,没有任何变化。即使将它设置为 2 的低计数仍会返回 100,所以就好像我的应用程序完全忽略了那行代码。

最佳答案

默认的 limit 是 100。

http://parseplatform.org/Parse-SDK-iOS-OSX/api/Classes/PFQuery.html#/Paginating%20Results

A limit on the number of objects to return. The default limit is 100, with a maximum of 1000 results being returned at a time.

所以只要调用:

query.limit = xxx

这是在 Parse Server v2.1.0 中添加的:

Fix: Making a query without a limit now returns 100 results Reference: https://github.com/parse-community/parse-server/blob/master/CHANGELOG.md#210-2172016

源代码:https://github.com/parse-community/parse-server/blob/master/src/Routers/ClassesRouter.js#L117


还有一个名为maxLimit 的相关参数,它是服务器范围的,表示查询的限制选项的最大值,默认为无限制

关于ios - PFQuery 只返回 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48771677/

相关文章:

ios - Swift - 如何更改当前用户位置标记的描述?

facebook - 调用 Parse Facebook 登录时发出 SIGABRT 信号

ios - 根据与 Float 的差异对解析查询进行排序

ios - 如何使用FTP直接从iOS将图像上传到服务器目录

ios - 单击移动 SKSpriteNode,但长按时连续移动 - Sprite Kit

ios - 从 UIPickerview 选择数据时如何以字符串格式显示 UIlabel

javascript - 用循环解析 Promise

Delphi Baas解析查询限制100条记录

ios - 无法从 Parse.com 获取 currentUser PFUser 对象

ios - Parse.com 多个用户访问数据 - Swift