-2

I have the following string :

Item 1#Item 2#Item 3#Item 4#Item 5#Item 6#Item 7#Item 8#Item 9#Item 10#Item 11#Item 12#Item 13#Item 14#Item 15#

I want to extract each Item name. How can it be done?

Vaibhav Jhaveri
  • 1,579
  • 3
  • 28
  • 53

3 Answers3

3

try this

NSString *temp = @"Item 1#Item 2#Item 3#Item 4#Item 5#Item 6#Item 7#Item 8#Item 9#Item 10#Item 11#Item 12#Item 13#Item 14#Item 15#";
    NSArray *arr = [temp componentsSeparatedByString:@" "];
    NSLog(@"%@", arr);
RAJA
  • 1,214
  • 10
  • 13
0

Separate each string

NSString *str = @"Item 1#Item 2#Item 3#Item 4#Item 5#Item 6#Item 7#Item 8#Item 9#Item 10#Item 11#Item 12#Item 13#Item 14#Item 15#";
NSArray *components = [str componentsSeparatedByString:@"#"];
Kampai
  • 22,848
  • 21
  • 95
  • 95
0
NSString *string=@"Item 1#Item 2#Item 3#Item 4#Item 5#Item 6#Item 7#Item 8#Item 9#Item 10#Item 11#Item 12#Item 13#Item 14#Item 15#";

NSArray *array=[[NSArray alloc] initWithObjects:[string componentsSeparatedByString:@"#"]];
hardik hadwani
  • 556
  • 6
  • 24