I have a string of 4 words, how do I separate it into 2 strings each consisting of two words?
The code:
NSString * myString= @"AAAA bbbbb CCCC ddddd";
I want to separate this string into 2 strings:
NSString *firstString =@"AAAA bbbbb";
NSString *secondString =@"CCCC ddddd";
You can use NSArray’s
componentsSeperatedByStringto break the string up into parts. From there you can use some simple string formatting to piece the new strings together from the contents of the array.