Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8233569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:10:27+00:00 2026-06-07T18:10:27+00:00

I have two elements: NSMutableArray* mruItems; NSArray* mruSearchItems; I have a UITableView that holds

  • 0

I have two elements:

NSMutableArray* mruItems;
NSArray* mruSearchItems;

I have a UITableView that holds the mruSearchItems basically, and once the user swipes and deletes a specific row, I need to find ALL matches of that string inside the mruItems and remove them from there.

I haven’t used NSMutableArray enough and my code gives me errors for some reason:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
    //add code here for when you hit delete
    NSInteger i;
    i=0;
    for (id element in self.mruItems) {
        if ([(NSString *)element isEqualToString:[self.mruSearchItems objectAtIndex:indexPath.row]]) {

            [self.mruItems removeObjectAtIndex:i];
        }
        else
           {
            i++;
           }
    }
    [self.searchTableView reloadData];

}    

}

Error:
I see now that some of the strings are not between quotation marks (the ones in UTF8 are though)

Terminating app due to uncaught exception 'NSGenericException', reason: '*** Collection <__NSArrayM: 0x1a10e0> was mutated while being enumerated.(
    "\U05de\U05e7\U05dc\U05d3\U05ea",
    "\U05de\U05d7\U05e9\U05d1\U05d5\U05df",
    "\U05db\U05d5\U05e0\U05df",
    "\U05d1 ",
    "\U05d1 ",
    "\U05d1 ",
    "\U05d1 ",
    Jack,
    Beans,
    Cigarettes
)'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T18:10:31+00:00Added an answer on June 7, 2026 at 6:10 pm

    You get an exception because you are mutating a container while iterating over its elements.

    removeObject: does exactly what you’re looking for: removing all objects that are equal to the argument.

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (editingStyle != UITableViewCellEditingStyleDelete)
            return;
    
        NSString *searchString = [self.mruSearchItems objectAtIndex:indexPath.row];
        [self.mruItems removeObject:searchString];
        [self.searchTableView reloadData];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two span elements that I would like to stay on the same
I have two div elements that are twins (i.e. their dimensions and contents are
I have two elements on the same page that are using the same stylesheet:
I have two elements that I would like to select <input id=iMe /> and
I have two form elements on my page that act as a smooth login
I have two elements that shouldn't be active at the same time, so when
I have two elements on a page that I'd like to animate via CSS
I have two elements (a field and some text) that I would like to
I have two elements that I am trying to line up, a text box
I have two HTML elements that share the same space- when one is visible,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.