Skip to content

Instantly share code, notes, and snippets.

@jarodl
Created November 18, 2011 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarodl/1378143 to your computer and use it in GitHub Desktop.
Save jarodl/1378143 to your computer and use it in GitHub Desktop.
#import <Foundation/Foundation.h>
@interface NSString (charactersAsArray)
- (NSArray *)charactersAsArray;
@end
#import "NSString+charactersAsArray.h"
@implementation NSString (charactersAsArray)
- (NSArray *)charactersAsArray
{
NSMutableArray *characters = [NSMutableArray arrayWithCapacity:[self length]];
for (int i = 0; i < [self length]; i++)
[characters addObject:[self substringWithRange:NSMakeRange(i, 1)]];
return characters;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment