Created
June 17, 2012 07:00
-
-
Save darcyliu/2943752 to your computer and use it in GitHub Desktop.
Categories
This file contains hidden or 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
// | |
// 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 |
This file contains hidden or 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
// | |
// 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