keysOfEntriesPassingTest:
Returns the set of keys whose corresponding value satisfies a constraint described by a block object.
- (NSSet *)keysOfEntriesPassingTest:(BOOL (^)(id key, id obj, BOOL *stop))predicate
Parameters of [NSDictionary keysOfEntriesPassingTest]
- predicate
- A block object that specifies constraints for values in the dictionary.
Return Value
The set of keys whose corresponding value satisfies predicate.
Example of [NSDictionary keysOfEntriesPassingTest]
NSSet * mySet = [myDict keysOfEntriesPassingTest:^(id key, id obj, BOOL *stop) {
if( [[obj port] isEqual: [NSNumber numberWithInt: 8080]]) {
return key;
}]
Example of [NSDictionary keysOfEntriesPassingTest]
mySet = [myDict keysOfEntriesPassingTest:^(id key, id obj, BOOL *stop) {
if ([[obj objectAtIndex:2] isEqualToString:@"America/Adak"]) {
return YES;
} else {
return NO;
}];
Example of [NSDictionary keysOfEntriesPassingTest]
NSArray * selectedKeys = [dict keysOfEntriesPassingTest:^(id key, id obj, BOOL *stop)
{
return [obj containsObject:[NSNumber numberWithInt:2]];
}];