Skip to content

Instantly share code, notes, and snippets.

@darcyliu
Created June 17, 2012 07:00
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 darcyliu/2943752 to your computer and use it in GitHub Desktop.
Save darcyliu/2943752 to your computer and use it in GitHub Desktop.
Categories
//
// NSString+Split.h
// Categories
//
// Created by Darcy Liu on 6/17/12.
// Copyright (c) 2012 Close To U. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (Split)
-(NSArray *)split;
@end
//
// NSString+Split.m
// Categories
//
// Created by Darcy Liu on 6/17/12.
// Copyright (c) 2012 Close To U. All rights reserved.
//
#import "NSString+Split.h"
@implementation NSString (Split)
-(NSArray *)split{
unsigned int length = [self length];
NSMutableArray *splitArray = [NSMutableArray arrayWithCapacity:length];
unsigned int i = 0;
while (i <length)
[splitArray addObject:
[NSString stringWithFormat:@"%c", [self characterAtIndex:i++]]];
return splitArray;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment