开发者

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" ]
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜