I want to filter an array of arrays using another array which is a subset of these arrays.
NSMutableArray* y = [NSMutableArray arrayWithObjects:@"A",@"B", nil];
NSArray *array = @[
@[@"A", @"B", @"C"],
@[@"A", @"B", @"E"],
@[@"A", @"B", @"D"],
@[@"B", @"C", @"D"],
];
I want to filter the second array such that it contains the items which has both "A" and "B" in it.
I used the predicate:
NSPredicate *intersectPredicate =[NSPredicate predicateWithFormat:@"ANY SELF IN %@", y];
NSArray *intersect = [array filteredArrayUsingPredicate:intersectPredicate];
But this gives me all the items in second Array. I think ANY/SOME is considering (A || B) I want to have (A && B). I tried ALL but it gives nothing.