public
Created

NSString+split

  • Download Gist
NSString+split.h
Objective-C
1 2 3 4 5 6 7 8
 
// Based upon: http://stackoverflow.com/a/13839284/439096
 
#import <Foundation/Foundation.h>
 
@interface NSString (split)
@property (nonatomic, readonly) NSArray *split;
@end
NSString+split.m
Objective-C
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.