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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:25+00:00 2026-05-28T04:22:25+00:00

I need your help :( I’m working on a iOS application in which i

  • 0

I need your help 🙁

I’m working on a iOS application in which i had to remove some rows and sections in a UItableView.

I’m on Xcode 4.

I associate my tableView with NSarray and dictionary, like this :

NSMutableArray *arrTemp1 = [[NSMutableArray alloc]
                         initWithObjects:@"Chris",nil];

    NSMutableArray *arrTemp2 = [[NSMutableArray alloc]
                         initWithObjects:@"Bianca",nil];

    NSMutableArray *arrTemp3 = [[NSMutableArray alloc]
                         initWithObjects:@"Candice",@"Clint",@"Chris",nil];

    NSMutableArray *arrTemp4 = [[NSMutableArray alloc]
                                initWithObjects:@"Candice",@"Clint",@"Chris",nil];

    NSMutableArray *arrTemp5 = [[NSMutableArray alloc]
                                initWithObjects:@"Candice",@"Clint",@"Chris",nil];

    NSMutableArray *arrTemp6 = [[NSMutableArray alloc]
                                initWithObjects:@"Candice",@"Clint",@"Chris",nil];

    NSMutableDictionary *temp = [[NSMutableDictionary alloc]
                         initWithObjectsAndKeys:arrTemp1,@"A",arrTemp2,
                                 @"B",arrTemp3,@"C",arrTemp4, @"D", arrTemp5, @"E", arrTemp6, @"J",nil];
    self.tableContents = temp;
    self.sortedKeys =[[self.tableContents allKeys]
                      sortedArrayUsingSelector:@selector(compare:)];

When i need to delete a rows or a sectionm i’m using this code ->

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

    if (editingStyle == UITableViewCellEditingStyleDelete)
    {   
        NSMutableArray *listData = [self.tableContents objectForKey:
                            [self.sortedKeys objectAtIndex:[indexPath section]]];
        NSUInteger row = [indexPath row];

        [listData removeObjectAtIndex:row];

        [tableView beginUpdates];


        if ([listData count] > 0)
        {
            // Section is not yet empty, so delete only the current row.
            [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                             withRowAnimation:UITableViewRowAnimationFade];
        }
        else
        {
            // Section is now completely empty, so delete the entire section.
            [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] 
                     withRowAnimation:UITableViewRowAnimationFade];
        }

       [tableView endUpdates];
    }
}

When i’m deleting rows, it works well..
When i’m deleting sections, i’m getting the following error :
” * Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit/UIKit-1912.3/UITableView.m:1030
2012-01-13 16:42:45.261 *
Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Invalid update: invalid number of sections. The number of sections contained in the table view after the update (6) must be equal to the number of sections contained in the table view before the update (6), plus or minus the number of sections inserted or deleted (0 inserted, 1 deleted).'”

 (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return [tableContents count]; // tableContent is a NSMUtableDictionnary*
}

- (NSInteger)tableView:(UITableView *)table
 numberOfRowsInSection:(NSInteger)section 
{
    NSArray *listData =[self.tableContents objectForKey:
                        [self.sortedKeys objectAtIndex:section]];
    return [listData count];
}

I’m getting crazy, and coming on stackOverflow to ask for help…

(Sorry for my poor english 🙁 )

Thanks to everyone reading and answering !!

  • 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-28T04:22:26+00:00Added an answer on May 28, 2026 at 4:22 am

    It looks like you’re not actually deleting the dictionary key for the empty array when it contains no objects, thus your call to

            // Section is now completely empty, so delete the entire section.
            [tableView deleteSections:[NSIndexSet indexSetWithIndex:indexPath.section] 
                     withRowAnimation:UITableViewRowAnimationFade];
    

    is causing the problem as you still have the same number of sections (dictionary keys) as before…

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

Sidebar

Related Questions

I've some questions .. and I really need your help. I have an application.
I need your help with the following scenario: I am reading some data from
need your help. I am able to print a document from iphone having ios
I need your help with a short bash script. I have a folder, which
Need your help. I created a static semi-opaque banner which stays at the top
I need your help....I'm working on a little Time Management Sytem for my compagny.
I need your help, For example I have a decimal type variable and I
I need your help to define a special case in XML schema: A sequence
I really need your help in my issue very quickly and it's too close
I really need your help for this. I am relatively new to programming and

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.