NSString's Split and Join crash course

Split a NSString is using the NSString instance method "componentsSeparatedByString"


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

Popular posts from this blog

Generating INSERT statement from SELECT using SQuirreL SQL

OneNote: We need the password to sync this notebook (Error code: 0xE4010643)

Fixing the AKE BC398 USB3.0 sluggish performance