2

正在缓存基本的 Parse.com 查询,但我无法缓存此特定查询,我已按照建议运行了很多次,并且缓存的结果始终为零。请提出解决方案。

PFQuery *lotsOfWins = [PFQuery queryWithClassName:@"Class1"];
[lotsOfWins whereKey:@"Score" equalTo:@"0:]; //AND
[lotsOfWins whereKey:@"Status" notEqualTo:@"4"];

PFQuery *fewWins = [PFQuery queryWithClassName:@"Class2"];
[fewWins whereKey:@"NAME" equalTo:@"KHAN"]; AND
[fewWins whereKey:@"meetingStatus" notEqualTo:@"4"];


PFQuery *query = [PFQuery orQueryWithSubqueries:[NSArray arrayWithObjects:fewWins,lotsOfWins,nil]];
[query orderByDescending:@"updatedAt"];
query.limit = [NSNumber numberWithInt:10];
query.cachePolicy = kPFCachePolicyCacheThenNetwork; // CACHE POLICY
[query findObjectsInBackgroundWithBlock:^(NSArray *results, NSError *error) {

    NSLog(@"Successfully retrieved %d results.", results.count);
    if(error) {
        NSLog(@"It's an error!");
    }
}];
4

2 回答 2

0

删除查询限制解决了这个问题。显然子查询不支持限制。

query.limit = [NSNumber numberWithInt:10]; //删除

于 2013-07-06T17:24:34.087 回答
0

Limit,是一个 NSInteger 属性,而不是 NSNumber。试过 query.limit = 10 并且工作得很好。

于 2015-09-11T22:53:41.187 回答