how to split a string on the iPhone?
iphone, objective-c
Solution
As others have mentioned, you can use `NSString's` member function `componentsSeparatedByString:` or `componentsSeparatedByCharactersInSet:`
As an alternative (for more powerful tokenizing), look into the Objective-C NSScanner class in the foundation framework of Mac OS X.
You could do something like this:
NSString *str = "drwxr-xr-x 9 0 ... ";
NSScanner *scanner = [NSScanner scannerWithString:str];
In order to obtain each token in string form, use `NSScanner's` `scanUpToCharactersFromSet:intoString:` member function.
NSString *token = [NSString string];
NSCharacterSet *div = [NSCharacterSet whitespaceCharacterSet];
[scanner scanUpToCharactersFromSet:div intoString:token];
// token now contains @"drwxr-xr-x"
Subsequent calls to the above would return 9, 0, and so on.
Note: the code above has not been tested.
Problem
I have got below value(dynamic) from the server: ``` drwxr-xr-x 9 0 0 4096 Jan 10 05:30 California ``` Now i want to get valu like this. ``` drwxr-xr-x 9 0 0 4096 Jan 10 05:30 California ``` Please help me for this question