I am having a string @"sairam". I need a characters separately and i need to store it into an ARRAY like
array = [@"s",@"a",@"i",@"r",@"a",@"m"];
how to do this give a loop like if i give a string it needs to divide charecters and store it into an array ...
thanks in advance...
From http://www.idev101.com/code/Objective-C/Strings/split.html:
NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myString length]];
for (int i=0; i < [myString length]; i++) {
NSString *ichar = [NSString stringWithFormat:@"%c", [myString characterAtIndex:i]];
[characters addObject:ichar];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With