2013-07-04 91 views
2

基本Parse.com查詢正在緩存,但我無法緩存這個特定的查詢,我已經跑了很多次,因爲建議和緩存結果總是零。請告知解決方案。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!"); 
    } 
}]; 

回答

0

限制,是NSInteger屬性,不是NSNumber。嘗試query.limit = 10,工作得很好。

0

刪除查詢限制解決了問題。顯然,子查詢不支持限制。

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

+1

這是不正確的。限制是一個整數,而不是一個NSNumber。 query.limit = 10應該工作得很好。 –