Created
May 10, 2013 07:46
-
-
Save alexruperez/5553006 to your computer and use it in GitHub Desktop.
How to get all keys starting with a common NSString in a NSDictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSDictionary+AllKeysStartingWith.h | |
// | |
// Copyright (c) 2013 alexruperez. | |
// | |
#import <Foundation/Foundation.h> | |
@interface NSDictionary (AllKeysStartingWith) | |
- (NSArray*)allKeysStartingWith:(NSString*)onset; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSDictionary+AllKeysStartingWith.m | |
// | |
// Copyright (c) 2013 alexruperez. | |
// | |
#import "NSDictionary+AllKeysStartingWith.h" | |
@implementation NSDictionary (AllKeysStartingWith) | |
- (NSArray*)allKeysStartingWith:(NSString*)onset | |
{ | |
return [[self allKeys] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF BEGINSWITH[cd] %@", onset]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment