Is there any way to do this? I have a set of elements that I want to exclude from another set. I know that I could iterate over each element in my set and add it only to my filter if it is not in another set, but it would be nice if I could use the predicate.
A set of elements to exclude is not a set of objects of the same type; This is a set of strings; and I want to exclude anything from my first set if one of the attributes matches this line .... in other words:
NSMutableArray *filteredArray = [NSMutableArray arrayWithCapacity:self.questionChoices.count];
BOOL found;
for (QuestionChoice *questionChoice in self.questionChoices)
{
found = NO;
for (Answer *answer in self.answers)
{
if ([answer.units isEqualToString:questionChoice.code])
{
found = YES;
break;
}
}
if (!found)
[filteredArray addObject:questionChoice];
}
Can this be done using a predicate?
source
share