Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to get all keys starting with a common NSString in a NSDictionary
//
// NSDictionary+AllKeysStartingWith.h
//
// Copyright (c) 2013 alexruperez.
//
#import <Foundation/Foundation.h>
@interface NSDictionary (AllKeysStartingWith)
- (NSArray*)allKeysStartingWith:(NSString*)onset;
@end
//
// 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
You can’t perform that action at this time.