1

私のプロジェクトでは、NSPredicate で作業しています。すでに単一の NSPredicate で作業していますが、複数の NSPredicate を使用する必要があります。

私はそのような3つのチェックボックスを持っています.最初はすべてがチェックされています.緑のボタンを選択解除すると、赤と黄色の値のみが表示されます.黄色の選択を解除すると、再び赤の値のみが表示されます.緑を選択すると、緑と赤の値

すなわち

1.Color is equal or not equal to Green.
2.Color is equal or not equal to Yellow.
3.Color is equal or not equal to Red.

これらの3色の組み合わせを持つ私の配列ここで私は試しました、

NSPredicate *filterRun,*filterNotProd,*filterStop,*filterR;

    if(isRun){
        filterRun = [NSPredicate predicateWithFormat:@"Color != [c] %@",GREEN_COLOR];
    }
    else{
        filterRun = [NSPredicate predicateWithFormat:@"Color == [c] %@",GREEN_COLOR];
    }

    if(isNotProd){
        filterNotProd = [NSPredicate predicateWithFormat:@"Color != [c] %@",YELLOW_COLOR];
    }
    else{
        filterNotProd = [NSPredicate predicateWithFormat:@"Color == [c] %@",YELLOW_COLOR];
    }


    if(isStop){
        filterStop = [NSPredicate predicateWithFormat:@"Color != [c] %@",RED_COLOR];
    }
    else{
        filterStop = [NSPredicate predicateWithFormat:@"Color == [c] %@",RED_COLOR];
    }
//        filterR = [NSPredicate predicateWithFormat:@"Color LIKE[c] %@",RED_COLOR];       

        NSLog(@"prediStr Runn %@ nnn %@ sss %@",filterRun,filterNotProd,filterStop);
        NSPredicate *compFilter=[NSCompoundPredicate andPredicateWithSubpredicates:@[filterRun,filterNotProd,filterStop]];
//        NSPredicate *compFilter=[NSCompoundPredicate orPredicateWithSubpredicates:@[filterRun,filterNotProd,filterStop]];

        NSMutableArray *filteredArr = [NSMutableArray arrayWithArray:[parkDetailsArr filteredArrayUsingPredicate:compFilter]];
        parkDetailsArr=[NSMutableArray arrayWithArray:filteredArr];

しかし、空の値しか表示されません..助けてください..

4

1 に答える 1