Is there a reason for NSDictionary
to return its keys as NSArray
instead of NSSet
? The documentation already states that the order of the
Usually you would want to do something with the keys, in which case it is simpler to use this NSDictionary method:
- (NSSet *)keysOfEntriesPassingTest:(BOOL (^)(KeyType key, ObjectType obj, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0);
This saves time because now you don't need to filter your array using a predicate, you can just perform your test in here and you get a set back. Simple.
Furthermore, you can take advantage of multi-processor concurrency by passing the concurrent enumeration option to this version of the method:
- (NSSet *)keysOfEntriesWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(KeyType key, ObjectType obj, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0);