I have a NSString: @"1a,1b,1c,1d,5c"
. I want this NSString separated into a NSMutableArray, but I don't know how. I think it is fairly simple but I can't find it (maybe because my English isn't good enough to find a good description for it to search on).
Regards, Dodo
NSString *_stringToSplit = @"1a,1b,1c,1d,5c";
NSArray *_splitItems = [_stringToSplit componentsSeparatedByString:@","];
NSMutableArray *_mutableSplitItems = [NSMutableArray arrayWithCapacity:[_splitItems count]];
[_mutableSplitItems addObjectsFromArray:_splitItems];
[NSMutableArray arrayWithArray:[string componentsSeparatedByString:@","]];
Use -componentsSeparatedByString:
to explode.
The returned value is an NSArray. If you need an NSMutableArray, call the -mutableCopy
method on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With