A coleção <__ NSArrayM: 0x7fa1f2711910> foi modificada enquanto estava sendo enumerada

Há várias perguntas com títulos semelhantes, mas nenhuma delas me ajudou.

mas posso relacionar solução disso'NSGenericException', motivo: a coleção <__ NSArrayM: 0x7fabb400> foi modificada enquanto estava sendo enumerada&nbsp;pergunta com a minha pergunta.Porque essa terminação está acontecendo quando estou adicionando, removendo o objeto string com a matriz.

Erro:

Finalizando o aplicativo devido à exceção não capturada 'NSGenericException', motivo: '*** A coleção <__ NSArrayM: 0x7fa1f2711910> foi modificada enquanto estava sendo enumerada.'

Pilha de primeira chamada:

(

0   CoreFoundation                      0x00000001087b8c65 __exceptionPreprocess + 165
1   libobjc.A.dylib                     0x0000000108422bb7 objc_exception_throw + 45
2   CoreFoundation                      0x00000001087b85c4 __NSFastEnumerationMutationHandler + 132
3                                       0x0000000107e24cf5 -[ProfessionalRegSecond tableView:didDeselectRowAtIndexPath:] + 773
4   UIKit                               0x0000000109759d71 -[UITableView _deselectRowAtIndexPath:animated:notifyDelegate:] + 347
5   UIKit                               0x000000010974deea -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 187
6   UIKit                               0x000000010968062c _applyBlockToCFArrayCopiedToStack + 314
7   UIKit                               0x00000001096804a6 _afterCACommitHandler + 533
8   CoreFoundation                      0x00000001086ebca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
9   CoreFoundation                      0x00000001086ebc00 __CFRunLoopDoObservers + 368
10  CoreFoundation                      0x00000001086e1a33 __CFRunLoopRun + 1123
11  CoreFoundation                      0x00000001086e1366 CFRunLoopRunSpecific + 470
12  GraphicsServices                    0x000000010d6c8a3e GSEventRunModal + 161
13  UIKit                               0x000000010965c900 UIApplicationMain + 1282
14                                      0x0000000107de14cf main + 111
15  libdyld.dylib                       0x000000010b585145 start + 1
)

libc ++ abi.dylib: finalizando com exceção não capturada do tipo NSException

O que estou tentando fazer:

Eu preciso de matriz de tal forma que quando eu selecionar a célula que eu quero adicionar esse objeto à matriz e quando eu estiver desmarcando a linha, eu quero remover essa linha da matriz para que a matriz de resultados seja apenas entradas selecionadas. Como fazer isso ?

Aqui está o meu código

@implementation Professional

    {
         NSMutableArray *updatedLocalityArray; // alloc,init did in viewDidLoad
         NSString *toCheck;
    }

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

   {

        UITableViewCell *tableViewCell = [tableView cellForRowAtIndexPath:indexPath];

        NSLog(@"%@",tableViewCell.textLabel.text);

        toCheck = tableViewCell.textLabel.text;
        [updatedLocalityArray addObject:toCheck];
        NSLog(@"%@ *****", updatedLocalityArray);

   }

  - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
    {

        UITableViewCell *tableViewCell = [tableView cellForRowAtIndexPath:indexPath];
           NSLog(@"%@",tableViewCell.textLabel.text);

        for (NSString *test in updatedLocalityArray)
        {
            if ([test isEqualToString:tableViewCell.textLabel.text])
            {

                [updatedLocalityArray removeObject:test];
                NSLog(@"%@ *****", updatedLocalityArray);

            }

        }

    }