Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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' as two differents strings? And how can i call it?

Thanks!

like image 384
Lucas Veiga Avatar asked Nov 03 '10 19:11

Lucas Veiga


1 Answers

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" ]
like image 169
Brad Avatar answered Sep 19 '22 17:09

Brad