Pages

Sunday, July 28, 2013

Split String in xCode

Suppose we have a String nums = "123,456,678,135,246,468,680"

Now if we want each number separated in an array then we can use the following method


NSArray *resultAr = [nums componentsSeparatedByString:@"|"]; 

Now we can track them by following


NSLog(@" %i %i %i", resultAr[0], resultAr[1], resultAr[2]);