-1

I have this string, inside the variable 'strings':

NSMutableArray *array_strings;
NSString *strings = @"one<-+->two<-+->three";

The separator string is "<-+->". I want to place certain words from the string within an array, as below:

  • [0] -> one
  • [1] -> two
  • [3] -> three
jscs
  • 63,694
  • 13
  • 151
  • 195
user3372120
  • 134
  • 1
  • 10

1 Answers1

1

Try:

array_strings = [[string componentsSeparatedByString:@"<-+->"] mutableCopy];

Notes:

  1. array_strings should really be named arrayStrings
  2. strings should generally be named as a singular, not plural (plural would be used for collections)
  3. Scan the methods on a class to see what's readily available ;-)
Wain
  • 118,658
  • 15
  • 128
  • 151