Reputation: 474
I hava a NSString which uses $ as delimiters, e.g.
NSMutableString *str = @"AA$BB$CC";
So, my questio is: is there a method to split that NSMutableString by delimiters '$' and store into an array, just like in java:
String[] list = str.split()
thanks advancde.
Upvotes: 1
Views: 1068
Reputation: 13713
NSArray* splittedArray= [str componentsSeparatedByString:@"$"];
for (NSString *component in splittedArray) {
NSLog(@"%@", component);
}
Upvotes: 5
Reputation: 3324
Yes. you can use componentsSeparatedByString
method which works similar to split()
method. Example:NSArray* list= [str componentsSeparatedByString:@"$"];
Upvotes: 1