Split NSString into Array
Hey everbody, i'm trying to convert one string to an array. My php is setting this:
echo "Logged/".$name;
So, how can i take 'Logged' and the 'Name开发者_JAVA百科' as two differents strings? And how can i call it?
Thanks!
If you read your string like: "logged/name" into an NSString
, you can use
- (NSArray *)componentsSeparatedByString:(NSString *)separator
to split it, like:
NSString *list = @"logged/name";
NSArray *listItems = [list componentsSeparatedByString:@"/"];
Would produce an NSArray
of two NSStrings
:
[ @"logged", @"name" ]
精彩评论