Take the 2-minute tour ×

If I want to explode a string by parts in PHP into an array, I have the nifty explode() function where I just do the following

$mystring = "HI:THERE:HOW";
$stringarray = explode(":", $mystring);

And I get

$stringarray = (
  [0] = "HI"
  [1] = "THERE"
  [2] = "HOW"

Is there a similar function in Objective C that explodes a string into an array? Thanks for any help!

share|improve this question

1 Answer 1

up vote 61 down vote accepted
NSArray *stringArray = [myString componentsSeparatedByString:@":"];
share|improve this answer
+1 for sheer precision. –  Jonathan Grynspan Jun 30 '10 at 7:34

Your Answer


