views:

48

answers:

2

I have a string :

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

Where '+' is the delimiter.

I want to store each a,b,c,d in array. How can it be done in objective C?

+4  A: 
- (NSArray *)componentsSeparatedByString:(NSString *)separator

is the method you are looking for

NSArray *yourArray = [yourString componentsSeparatedByString:@"+"];
Gauloises
great answer, short and complete
Ayaz Alavi
A: 

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

Felixyz