Created
January 25, 2013 13:32
-
-
Save berikv/4634479 to your computer and use it in GitHub Desktop.
NSString+split
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
// Based upon: http://stackoverflow.com/a/13839284/439096 | |
#import <Foundation/Foundation.h> | |
@interface NSString (split) | |
@property (nonatomic, readonly) NSArray *split; | |
@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
#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