-1

大家好,我正在与我一起工作,我正在使用 parse.com PFQuery 或 QuerywithSubqueries

到目前为止,一切都运行良好,现在我需要添加第四个查询,但是当我运行时应用程序不断崩溃......有谁知道为什么会发生这种情况?

- (void)  QueryForPost {
    
    PFUser CurrentGoUser * = [ PFUser currentUser ] ;
    
    PFQuery QueryForFriend * = [ PFQuery queryWithClassName : FF_AMICIZIE_CLASS ] ;
    [ QueryForFriend whereKey : FF_AMICIZIE_A_USER equalTo : CurrentGoUser ] ;
    [ QueryForFriend whereKey : FF_AMICIZIE_STATO equalTo : @ " Confirmed "];
    [ QueryForFriend includeKey : FF_AMICIZIE_DA_USER ] ;
        
    PFQuery QueryForPost * = [ PFQuery queryWithClassName : FF_POST_CLASS ] ;
    [ QueryForPost whereKey : FF_POST_FLASH_POST_BOOLEANVALUE equalTo : [ NSNumber numberWithBool : YES] ] ;
    [ QueryForPost whereKey : FF_POST_SCELTI equalTo : CurrentGoUser ] ;

    PFQuery normalPostByFriends * = [ PFQuery queryWithClassName : FF_POST_CLASS ] ;
    [ normalPostByFriends whereKey : FF_POST_FLASH_POST_BOOLEANVALUE equalTo : [ NSNumber numberWithBool : NO ]] ;
    [ normalPostByFriends whereKey : FF_POST_UTENTE matchesKey : FF_AMICIZIE_DA_USER inquery : QueryForFriend ] ;
    
    PFQuery normalPostByUser * = [ PFQuery queryWithClassName : FF_POST_CLASS ] ;
    [ normalPostByUser whereKey : FF_POST_FLASH_POST_BOOLEANVALUE equalTo : [ NSNumber numberWithBool : NO ]] ;
    [ normalPostByUser whereKey : FF_POST_UTENTE equalTo : CurrentGoUser ] ;
    
    PFQuery queryForGoPointStatus * = [ PFQuery queryWithClassName : @ " goPoint "];
    [ queryForGoPointStatus whereKey : @ " AssegnatoDa " equalTo : CurrentGoUser ] ;


    PFQuery * query = [ PFQuery orQueryWithSubqueries : @ [ QueryForPost , normalPostByFriends , normalPostByUser , queryForGoPointStatus ]] ;
    [ query includeKey : FF_POST_UTENTE ] ;
    [ includeKey query : @ " AssegnatoDa "];
    [ query OrderByDescending : FF_CREATEDAT ] ;
  
    [ query findObjectsInBackgroundWithBlock : ^ ( NSArray * results, NSError * error ) {
       
        if (! error) {
            ArrayforPost = [ [ NSMutableArray alloc] init ] ;
            for ( PFObject * object in results ) {
                [ ArrayforPost addObject : object ] ;
            }
            [ self.FFTableView reloadData ] ;
        Else { }
            NSLog ( @ " Erroreeeee :% @" , error) ;
        }
    } ] ;
   
}
4

1 回答 1

1

异常消息说明了一切:All sub queries of an or query should be on the same class。所以你只能在FF_POST_CLASSor上使用谓词FF_AMICIZIE_CLASS,但不能同时使用。由于它是一个OR谓词,您只需发出 2 个请求并合并结果。

于 2013-11-27T18:37:05.490 回答