I have an NSArray full of dictionaries.
I want to loop through it and find all dictionaries that have an key value matching any of the string object that exists within a separate array.
I then want to add this to a new results array of all objects found.
This is how I do it now, but I wanted to know if there is a more efficient and faster way of doing this.
NSArray *arrayOfDictionaries, *arrayOfIDs;
NSMutableArray *results = [NSMutableArray array];
for (NSDictionary *dict in arrayOfDictionaries) {
for (NSString *userID in arrayOfIDs) {
if ([userID isEqualToString:dict[@"user_id"]]) {
[results addObject:dict];
}
}
}
return results;