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 6093109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:22+00:00 2026-05-23T12:31:22+00:00

I have a NSMutableDictionary as the datasource for my UITableView. I am trying to

  • 0

I have a NSMutableDictionary as the datasource for my UITableView. I am trying to implement the delete mode and having an issue.

I am logging the key I am trying to remove as well as the object that it corresponds to as this issue seems like it might be related to my trying to access unallocated memory or something. Here is my implementation of tableView:commitEditionStyle:forRowAtIndexPath:

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

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.
        NSArray * keys = [userList allKeys];
        NSNumber *keyToRemove = [keys objectAtIndex:indexPath.row];
        NSLog(@"Key to remove: %@",keyToRemove);
        NSLog(@"Object at key: %@",[userList objectForKey:keyToRemove]);
           [userList removeObjectForKey:keyToRemove];   
              [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
        [keys release];
        [keyToRemove release];

    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
    }   
}

This method runs and then I get the error. The two NSLog statements output the correct key and it’s corresponding value.

Can someone tell me what I’m doing wrong?

Thanks

  • 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-23T12:31:23+00:00Added an answer on May 23, 2026 at 12:31 pm

    You don’t own keys or keysToRemove, so you should not be releasing them. I strongly suggest reading up on the Cocoa memory management rules.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an NSMutableDictionary with some song data (for example key: Artist object: Passion
I have a NSMutableDictionary with the key being the first alphabet of the name
I have a NSMutableDictionary, and my keys are objects (and the class implement the
I have a NSMutableDictionary with string keys and every key has its own array.
I have an NSMutableDictionary with three key/value pairs. key1 - person object1 key2 -
I have An NSMutableArray of NSMutableDictionary Which Looks like this Object 1 of Array
I have a NSMutableDictionary of NSMutableSets. Each set entry is a string, something like
I currently have a NSArrayController whose content property is (programmatically) set to an NSMutableDictionary
i have created NSMutableDictionary with 10 keys.Now i want to access NSMutableDictionary keys in
I'm stumped. I have an NSMutableDictionary w/ nested dictionaries that I am enumerating through

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.