Search NSArray for value matching value
I have an NSArray of objects , which has a particular property called name (type NSString). I have a second NSArray of NSStrings which are names . I'd like to get an NSArray of all the objects whose .name property matches one of the names in the second NSArray. How do I go about this, fast and efficiently as this will be required quite often. With your current data structures, you can only do it in O(n^2) time by looping over the first array once for each member of the second array: NSMutableArray * array = [NSMutableArray array]; for (NSString * name in names) { for (MyObject * object in