What is faster getting to an object from a collection?
a. Searching in an NSDictionary with [dictionary objectForKey:key];
or
b. Searching in an NSArray with [NSPredicate predicateWithFormat:@"someKey like %@",someKeyValue];
In both cases I create the collections.
Regards!
Assuming a well programmed dictionary, that’s going to be much faster. A good dictionary should find your key in constant time O(1) using a hashmap. If the array is sorted, knows that, and uses a binary search it can optimize to a binary search at O(log n), otherwise it will have to linearly look at every object, an O(n) operation. What would be best is if you could somehow make the key into a direct index, possibly with a one-time sort.