How to find the separator in lens C?

I have a line:

NSString *s = @"a+v+c+d";

Where '+'is the separator.

I want to save everyone a,b,c,din array. How can this be done in objective C?

+3
source share
2 answers
- (NSArray *)componentsSeparatedByString:(NSString *)separator

- the method you are looking for

NSArray *yourArray = [yourString componentsSeparatedByString:@"+"];
+6
source

-[NSString componentsSeparatedByString:]returns a, v, c, d as elements in NSArray. Use -[NSString componentsSeparatedByCharactersInSet:]if you have more than one separator.

+1
source

Source: https://habr.com/ru/post/1761710/


All Articles