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

  • Home
  • SEARCH
  • 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 6391501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:40:46+00:00 2026-05-25T03:40:46+00:00

I am trying to figure out how to delete one item from this NSMutableArray

  • 0

I am trying to figure out how to delete one item from this NSMutableArray that I am using for a sectioned table. This is how I build the data source:

listOfItems = [[NSMutableArray alloc] init];

NSArray *appleComputers = [NSArray arrayWithObjects:@"iPhone",@"iPod",@"MacBook",@"MacBook Pro",nil];
NSDictionary *appleComputersDict = [NSDictionary dictionaryWithObject:appleComputers forKey:@"Computers"];

NSArray *otherComputers = [NSArray arrayWithObjects:@"HP", @"Dell", @"Windows", nil];
NSDictionary *otherComputersDict = [NSDictionary dictionaryWithObject:otherComputers forKey:@"Computers"];

[listOfItems addObject:appleComputersDict];
[listOfItems addObject:otherComputersDict];

I am trying to figure out how to delete, say “iPod” from this array? I have tried many things, among them the one below, but nothing worked.

    [listOfItems removeObjectAtIndex:indexPath.row];

(problem here is that there is no reference for the actual section…)

Thanks!

UPDATE: This is where I delete the row:

- (void)tableView:(UITableView *)aTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

if (editingStyle == UITableViewCellEditingStyleDelete) {


    NSMutableArray * section = [listOfItems objectAtIndex:indexPath.section];    
    [section removeObjectAtIndex:indexPath.row];
[tblSimpleTable reloadData];

} else if (editingStyle == UITableViewCellEditingStyleInsert) {

   // some code...
}

}

  • 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-05-25T03:40:46+00:00Added an answer on May 25, 2026 at 3:40 am

    Not sure why you’re using a dictionary… doesn’t seem like you need one. How about just an array of arrays?

    listOfItems = [[NSMutableArray alloc] init];
    
    NSMutableArray * appleComputers = [NSMutableArray arrayWithObjects:@"iPhone",@"iPod",@"MacBook",@"MacBook Pro",nil];
    [listOfItems addObject:appleComputers];
    
    NSMutableArray * otherComputers = [NSMutableArray arrayWithObjects:@"HP", @"Dell", @"Windows", nil];
    [listOfItems addObject:otherComputers];
    

    then

    NSMutableArray * section = [listOfItems objectAtIndex:indexPath.section];    
    [section removeObjectAtIndex:indexPath.row];
    

    Even if you do need to use the dictionaries, it’s still not a big deal… just use NSMutableArray instead of NSArray for your appleComputers or otherComputers and do this:

    NSDictionary * section = [listOfItems objectAtIndex:indexPath.section];
    NSMutableArray * sectionComputers = [section objectForKey:@"Computers"];    
    [sectionComputers removeObjectAtIndex:indexPath.row];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out why NHibernate handles one-to-many cascading (using cascade=all-delete-orphan) the way
I'm trying to delete the highest value from a group. Given this data: group_table
In trying to figure out this problem (which is still unsolved and I still
I am trying to figure out this: c = 1 def f(n): print c
I was trying to figure out why a debug build was blowing up with
I'm trying to figure out the best way to create a class that can
I'm trying to figure out the logic for creating tasks that have dependencies. In
I'm trying to figure out what is the best general design for applications that
I am trying to figure out how to remove a node from a binary
Hey all i am trying to figure out a way to delete something inside

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.