Reputation: 1795
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!
Upvotes: 14
Views: 25400
Reputation: 11505
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" ]
Upvotes: 44