Skip to content

Instantly share code, notes, and snippets.

@berikv
Created January 25, 2013 13:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save berikv/4634479 to your computer and use it in GitHub Desktop.
Save berikv/4634479 to your computer and use it in GitHub Desktop.
NSString+split
// Based upon: http://stackoverflow.com/a/13839284/439096
#import <Foundation/Foundation.h>
@interface NSString (split)
@property (nonatomic, readonly) NSArray *split;
@end
#import "NSString+split.h"
@implementation NSString (split)
- (NSArray *)split {
NSMutableArray *letterArray = [NSMutableArray array];
[self enumerateSubstringsInRange:NSMakeRange(0, self.length) options:(NSStringEnumerationByComposedCharacterSequences) usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
[letterArray addObject:substring];
}];
return letterArray;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment