NSString's Split and Join crash course
Split a NSString is using the NSString instance method "componentsSeparatedByString"
The above code will produce an array containing the following element:
To join an array of NSString back to a single NSString, use the NSArray instance method "componentsJoinedByString"
That will give you back the NSString
NSString *mystring = @"coding;is;kind;of;magic"; NSArray *mysplitedstring = [mystring componentsSeparatedByString: @";"];
The above code will produce an array containing the following element:
coding is kind of magic
To join an array of NSString back to a single NSString, use the NSArray instance method "componentsJoinedByString"
NSString *mystring = [mysplitedstring componentsJoinedByString:@";"];
That will give you back the NSString
"coding;is;kind;of;magic"
Comments
Post a Comment