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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:41:52+00:00 2026-05-22T02:41:52+00:00

I’m having a hard time wrapping my head around this. I’m loading up an

  • 0

I’m having a hard time wrapping my head around this. I’m loading up an NSMutable array from a plist file and populating a grouped table with the data. The table has 3 sections, section 0 is not editable but the other two are – I have that limitation working. My issue is when the user chooses to delete a row in the two editable sections. I believe it’s because I have two keys for each entry – one for it’s name and the other for it’s url.

Here’s a sample of my plist. the Title key is used for the section names. Then there’s a key for ‘Rows’ – which is the text that shows in each cell and then ‘url’ which, when the row is selected, loads the url in a webview. I know that I want to grab the section and the row that the user selects and then delete both the ‘Row’ and ‘url’ for that index. Any help would be greatly appreciated.

Here’s my plist:

<array>
<dict>
<key>Title</key>
<string>Query</string>
    <key>Rows</key>
    <array>
        <string>Non-editable String 1</string>
        <string>Non-editable String 2</string>
        <string>Non-editable String 3</string>
        <string>Non-editable String 4</string>
    </array>
</dict>
<dict>
    <key>Title</key>
    <string>Resources</string>
    <key>Rows</key>
    <array>
        <string>Website Name 1</string>
        <string>Website Name 2</string>
        <string>Website Name 3</string>
        <string>Website Name 4</string>
        <string>Website Name 5</string>
    </array>
    <key>url</key>
    <array>
        <string>http://website1.com</string>
        <string>http://website2.com</string>
        <string>http://website3.com</string>
        <string>http://website4.com</string>
        <string>http://website5.com</string>
    </array>
</dict>
<dict>
    <key>Title</key>
    <string>Monitoring</string>
    <key>Rows</key>
    <array>
        <string>Website Name 6</string>
        <string>Website Name 7</string>
        <string>Website Name 8</string>
    </array>
    <key>url</key>
    <array>
        <string>http://website6.com</string>
        <string>http://website7.com</string>
        <string>http://website8.com</string>
    </array>
</dict>

This limits editing to the last two sections

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView     editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section == 0)
    return UITableViewCellEditingStyleNone;
else
    return UITableViewCellEditingStyleDelete;
}

This is (the non-working code) for committing the delete (tableData is the name of my mutable array). My app bombs at:

        [[self.tableData objectAtIndex:indexPath.section] removeObjectAtIndex:indexPath.row];

But guessing the deleteRowsAtIndexPaths is wrong too.
Code:

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

if (editingStyle == UITableViewCellEditingStyleDelete) {

    [self.tableView beginUpdates];
    [[self.tableData objectAtIndex:indexPath.section] removeObjectAtIndex:indexPath.row];

    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath.row] withRowAnimation:UITableViewRowAnimationFade];

    [self.tableView endUpdates];
    [self.tableView reloadData];
}

—UPDATE—
If I do it this way and set section and row to NSUInteger, when I log it, the correct section and row are logged. However, I’m crashing at

[[self.tableData objectAtIndex:section] removeObjectAtIndex:row];

In my console, I’m getting this error: Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[__NSCFDictionary removeObjectAtIndex:]: unrecognized selector sent to instance 0x4b43b20’

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

if (editingStyle == UITableViewCellEditingStyleDelete) {

    NSUInteger row = [indexPath row];
    NSLog(@"NSUInteger Row: %d", row);

    NSUInteger section = [indexPath section];
    NSLog(@"NSUInteger Section: %d", section);

    [self.tableView beginUpdates];

    [[self.tableData objectAtIndex:section] removeObjectAtIndex:row];

    [self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:[NSIndexPath indexPathForRow:row inSection:section]] withRowAnimation:UITableViewRowAnimationFade];
  • 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-22T02:41:53+00:00Added an answer on May 22, 2026 at 2:41 am

    For your plist, the tableData variable is an NSMutableArray that contains 3 objects each of which is an NSMutableDictionary (despite the fact that the docs say it should be an NSDictionary–immutable).

    The second and third dictionaries contain three keys: Title, Rows, and url

    The values of the Rows and url keys are NSMutableArrays (again despite the docs saying they should be NSArrays–immutable).

    Regardless, after reading the plist, the objects that you want to modify must one way or another be mutable either by default or by you explicitly calling mutableCopy.

    In the commitEditingStyle method, you need to call removeObjectAtIndex on the arrays and not the section dictionary. So first get a reference to the Rows and url arrays (you must be doing something similar in cellForRowAtIndexPath to display the values).

    -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath 
    {
        if (editingStyle == UITableViewCellEditingStyleDelete) 
        {
            NSMutableDictionary *sectionDict = [tableData objectAtIndex:indexPath.section];
            NSMutableArray *sectionRows = [sectionDict objectForKey:@"Rows"];
            NSMutableArray *sectionUrls = [sectionDict objectForKey:@"url"];
    
            [sectionRows removeObjectAtIndex:indexPath.row];
            [sectionUrls removeObjectAtIndex:indexPath.row];
    
            //don't need beginUpdates (we're making only one delete call)           
            //tableView beginUpdates];
    
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] 
                    withRowAnimation:UITableViewRowAnimationFade];
    
            //don't need endUpdates (since we're not doing beginUpdates)
            //[tableView endUpdates];
    
            //don't need reloadData since we're calling deleteRowsAtIndexPaths
            //(or call reloadData instead of deleteRowsAtIndexPaths)
            //[tableView reloadData];
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Does anyone know how can I replace this 2 symbol below from the string
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am currently running into a problem where an element is coming back from

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.