I have an array of dictionaries that I need to filter in a very specific way. It's easiest to explain by example.
Let's say I have an array containing the following three dictionaries where @"threadId", @"subject", @"messageId" are keys:
NSDictionary #1:
@"threadId" : @"1234"
@"subject" : @"hello"
@"messageId" : @"0001"
NSDictionary #2:
@"threadId" : @"1234"
@"subject" : @"hello"
@"messageId" : @"0002"
NSDictionary #3:
@"threadId" : @"9101"
@"subject" : @"goodbye"
@"messageId" : @"0005"
I'm considering any dictionary that has the same value for @"threadId" and @"subject" to be duplicates, EVEN IF the @"messageId" is different. Thus, I'd consider dictionary 1 and dictionary 2 to be duplicates, and I'd like to remove EITHER dictionary 1 OR dictionary 2 (not both) from the above array. In other words, I'd like to filter the original array of all three dictionaries into a new array containing EITHER dictionaries 1 and 3 OR dictionaries 2 and 3.
All of my attempts to do this so far have resulted in excessive for loops, in which I attempt to sort and separate dictionaries by threadId... but then I get stuck at the comparison part. I've looked at filtering by predicate but that looks like it only removes objects that meet a particular criteria that has nothing to do with comparison with other objects. NSSet won't work because the objects I'm considering to be duplicates aren't actually duplicates.
I'm wondering if anyone could suggest a general strategy for performing this filtration.