Is there any way to do this? I have a set of items that I want to exclude from another set. I know I could loop through each item in my set and only add it to my filteredSet if it's not in the other set, but it would be nice if I could use a predicate.
The set of items to exclude isn't a set of the same type of object directly; it's a set of strings; and I want to exclude anything from my first set if one of the attributes matches that string.... 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 with a predicate instead?