views:

42

answers:

1

Hi,

I am having a lengthy string which contains alphabets and a special character like "|". i need to split this strings based on the "|" delimiter and store the individual string in to an array. Is there any string function which helps us to do the same.?

Thanks, Shibin.

+2  A: 

Sounds like you need componentsSeparatedByString:

NSString *string = @"hello|how|are|you";
NSArray *array = [string componentsSeparatedByString:@"|"]; 
NSLog(@"array: %@", array);

Output:

array: (
    hello,
    how,
    are,
    you
    )
nevan
Thanks nevan.. it works....!
Shibin Moideen