gpt4 book ai didi

ios - PFQuery 只返回 100

转载 作者:行者123 更新时间:2023-11-29 00:03:23 25 4
gpt4 key购买 nike

我认为 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com