Parse.com缓存复合查询

时间:2013-07-04 21:13:29

标签: ios objective-c parse-platform

正在缓存基本的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!");
    }
}];

2 个答案:

答案 0 :(得分:0)

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

  

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

答案 1 :(得分:0)

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