• Home
  • Tutorials
  • Separating string by string into array in iOS Objective C
 
11
0
0

Separating string by string into array in iOS Objective C

How to separate Input String by separator string into Array. Analogue of Split() function.  



NSArray * myArray = [[NSArray alloc] init];


myArray = [@"12,34,45,56,78,90" componentsSeparatedByString:@","];


[myArray objectAtIndex:0] // 12
[myArray objectAtIndex:1] // 34
[myArray objectAtIndex:2] // 45
[myArray objectAtIndex:3] // 56
[myArray objectAtIndex:4] // 78
[myArray objectAtIndex:5] // 90


Discussion

-