You could simply enumerate the dictionary once and keep track of the largest value together with the corresponding key:
NSDictionary *dict = @{@"a": @1, @"b": @2, @"Not Specified": @3};
__block NSString *highKey;
__block NSNumber *highVal;
[dict enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSNumber *val, BOOL *stop) {
if (highVal == nil || [val compare:highVal] == NSOrderedDescending) {
if (![key isEqualToString:@"Not Specified"] ) {
highKey = key;
highVal = val;
}
}
}];
NSLog(@"key: %@, val: %@", highKey, highVal);
// Output: key: b, val: 2