I am trying to create an array of values that when printed, will look like the following:

```
    {
    headerTitle = "#";
    rowValues =         (
        ""
    );
    }        {
     headerTitle = A;
     rowValues =          (
        "Abaco Barb",
        Abenauer,
        "Australian Stockhorse",
    );
    }         {
      headerTitle = B;
         etc…

```

The program fails with a `"doesNotRecognizeSelector:"` error on the statement indicated below.

The array is defined as: 

```
NSMutableArray *words = [[NSMutableArray alloc]init];

```

**THE RELEVANT CODE:**

```
    else
    {
     letterString = [[dataArray objectAtIndex:i] substringToIndex:1];
     NSLog(@"lastLetter = %@",lastLetter);
     NSLog(@"letterString = %@",letterString);

      if ([lastLetter isEqualToString: letterString])
       {
           NSLog(@"before words, dataArray %@", [dataArray objectAtIndex:i]);

           //(FAILS on the next instruction on adding [dataArray objectAtIndex:i] =    
          // Abenauer)

           [words addObject:[dataArray objectAtIndex:i]];   
                        NSLog(@"words - %@",words);
           NSLog(@"after words");
       }
       else
       {
        NSMutableDictionary *row = [[NSMutableDictionary alloc] init];
        [row setValue:lastLetter forKey: @"headerTitle"];
        [row setValue: words forKey:@"rowValues"];
        [content addObject:row];
         NSLog(@"content - %@",content);
        lastLetter = letterString;
        words =[dataArray objectAtIndex:i];
                        NSLog(@"words - %@",words);
        }
     }

```

OUTPUT created before failure:

```
   2014-03-21 11:37:42.967 EquineDiary[1864:a0b] lastLetter = #
   2014-03-21 11:37:42.967 EquineDiary[1864:a0b] letterString = A
   2014-03-21 11:37:42.968 EquineDiary[1864:a0b] content - (
    {
    headerTitle = "#";
    rowValues =         (
    );
    }
    )
   2014-03-21 11:37:54.434 EquineDiary[1864:a0b] words - Abaco Barb
   2014-03-21 11:37:54.435 EquineDiary[1864:a0b] lastLetter = A
   2014-03-21 11:37:54.436 EquineDiary[1864:a0b] letterString = A
   2014-03-21 11:37:54.436 EquineDiary[1864:a0b] before words, dataArray Abtenauer

```

Thanking you in advance for your help.

NOTE 1:
The entire error is "CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]:" Words is defined at the beginning of the Method, outside of the for loop. "Abaco Barb" is already in words when I am trying to add "Abtenauer" which is in [dataArray objectAtIndex:i].

All I am trying to do is put all names that begin with "A" into an array (words) until the word no longer begins with A at which time I write the words array to a row with the key "row values". A is written to the row with a key "header titles".

NOTE 2:

I have discovered the issue but don't know how to fix it. After I write the data to row I have the code " words =[dataArray objectAtIndex:i];" for the purpose of wiping the previous values (i.e. "A" values) so that I can start adding words which begin with the next letter (i.e. "B"). It doesn't like adding objects to words after I do this. Why is this? And what is the best way to wipe the values to begin again?