I have an array of NSDictionaries that I would like to filter. Each dictionary contains the key "tid" which corresponds to a string object. I would like to pull out all dictionaries for which their object for key "tid" is NOT equal to any of the string objects contained in a separate array.
For example, if I have an array called "stringObjects" and an array of dictionaries called "dictionaries", in pseudo code I want to do:
for (NSString *string in stringObjects) {
//if a dictionary in dictionaries contains a string object for it's key @"tid" which is NOT equal to *string, then put it in an array
}
I've been trying to use NSPredicate to do this, but after several varied attempts, I can't get my desired result. Here is the code I most recently tried (which actually seems to create an array of every object for every dictionary in the array except objects for key @"tid"):
NSSet *savedThreadIds = //set of strings
NSMutableArray *filtered = [NSMutableArray array];
for (NSString *threadId in savedThreadIds) {
[filtered addObjectsFromArray:[arrayOfDictionaries filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"(%K != %@)", @"tid", threadId]]];
}
Any help is appreciated.