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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:06:35+00:00 2026-05-23T19:06:35+00:00

When i try to delete the cell i get crash … Assertion failure in

  • 0

When i try to delete the cell i get crash …

Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UITableView.m:976
2011-07-19 08:55:53.575 MyTable[477:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 1.  The number of rows contained in an existing section after the update (3) must be equal to the number of rows contained in that section before the update (4), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted).'

Below is my code

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    // Configure the cell...
    cell.textLabel.text = [aContentArray objectAtIndex:indexPath.row];
    cell.detailTextLabel.text =[aDetailTextArray objectAtIndex:indexPath.row];  
    cell.imageView.image = [UIImage imageNamed:@"home-picture.jpg"];

    return cell;
}
  • (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to display an Edit button in the
    navigation bar for this view controller.
    self.navigationItem.rightBarButtonItem = self.editButtonItem;
    aContentArray = [[NSMutableArray
    arrayWithObjects:@”iPhone”,@”Android”,@”Blackberry”,@”Symbian”,nil]retain];
    aDetailTextArray = [[NSMutableArray arrayWithObjects:@”iPhone is
    from Apple Inc”, @”Android is from Google and it is Open
    source”,@”Blackberry is from RIM Research In Motion”,@”Symbian is used
    from Nokia”,nil]retain];

}

// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source.
        [self.aDetailTextArray removeObjectAtIndex:indexPath.row];
        [self.aContentArray removeObjectAtIndex:indexPath.row];

        [tableView beginUpdates];

        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];

        [tableView endUpdates];

        [tableView reloadData];

    }   
    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.
    }   
}

Please help me out and 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-23T19:06:36+00:00Added an answer on May 23, 2026 at 7:06 pm

    The problem is that you delete the row but you do not remove that data from your datasource (read the error message again and you’ll see what I mean). Without seeing how your datasource is implemented it is hard to give an exact answer, but as a demonstration let’s say you keep your tableview contents in an NSMutableArray called items.

    [tableView beginUpdates];
    
    [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
    [items removeObjectAtIndex:indexpath.row]:
    [tableView endUpdates];
    //no need to call reloaddata
    

    Again, the exact method will depend on how your tableview is populated. The above is only an example of one particular case.

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

Sidebar

Related Questions

Whenever I click in a cell, and try to rename it, I get an
I get the following error while I try to delete a row while looping
When i set a table into editing mode and try to delete a cell,
I simply try to delete a row from a UITableView with the following code:
I get some super annoying asserts when I try to delete the leveldb instance
Through CommandName=Delete I try to delete a line from the ListView control but not
I'm looking to try to make an efficient delete method to work on a
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
Try as I might I cannot get my head around what the IteratorIterator class
Try as I might, I can't get a JNLP file to run locally (via

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.