Here's the trick :
Explode like :
Supposing that you've got an NSString named "string" containing several elements separated by a pipe "|", you can get an array of each strings just like this :
- Code: Select all
NSArray *myElements = [string componentsSeparatedByString: @"|"];
Implode like :
Now to get the reversed result (so have an Array of NSString and merging them into a single NSString "glued" with a separator string, do that :
- Code: Select all
string = [myElements componentsJoinedByString: @"|"];
Don't forget that the glue/unglue string (the seperator) is... a string. So you also can use complex combination, not only one char.
