I recently found a really good tutorial on Objective-C Strings:
http://ios-blog.co.uk/tutorials/objective-c-strings-a-guide-for-beginners/
And I thought that this might be of interest:
If you want to split the string into an array use a method called componentsSeparatedByString to achieve this:
NSString *yourString = @"This is a test string";
NSArray *yourWords = [myString componentsSeparatedByString:@" "];
// yourWords is now: [@"This", @"is", @"a", @"test", @"string"]
if you need to split on a set of several different characters, use NSString’s componentsSeparatedByCharactersInSet:
NSString *yourString = @"Foo-bar/iOS-Blog";
NSArray *yourWords = [myString componentsSeparatedByCharactersInSet:
[NSCharacterSet characterSetWithCharactersInString:@"-/"]
];
// yourWords is now: [@"Foo", @"bar", @"iOS", @"Blog"]
Note however that the separator string can’t be blank. If you need to separate a string into its individual characters, just loop through the length of the string and convert each char into a new string:
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];
}