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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:07:46+00:00 2026-06-17T13:07:46+00:00

How to delete the row in section at UITableView ? It will crash when

  • 0

How to delete the row in section at UITableView?

It will crash when I run the code below:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView beginUpdates];
    if (editingStyle == UITableViewCellEditingStyleDelete) {


        NSIndexPath *firstRow = [NSIndexPath indexPathForRow:0 inSection:0];
        //[self.productItems removeObjectAtIndex:indexPath.row];


        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationRight];
    }
    [tableView endUpdates];
}

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1447.6.4/UITableView.m:976
2013-01-19 14:46:14.847 [4752:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 2.  The number of rows contained in an existing section after the update (1) must be equal to the number of rows contained in that section before the update (1), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).'
*** Call stack at first throw:
(
    0   CoreFoundation                      0x0174abe9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x0189f5c2 objc_exception_throw + 47
    2   CoreFoundation                      0x01703628 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x0054c47b -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
    4   UIKit                               0x007cea0f -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 8424
    5   UIKit                               0x007be433 -[UITableView endUpdates] + 42

    7   UIKit                               0x007bb2ea -[UITableView(UITableViewInternal) animateDeletionOfRowWithCell:] + 101
    8   UIKit                               0x00751a6e -[UIApplication sendAction:to:from:forEvent:] + 119
    9   UIKit                               0x007e01b5 -[UIControl sendAction:to:forEvent:] + 67
    10  UIKit                               0x007e2647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
    11  UIKit                               0x007e11f4 -[UIControl touchesEnded:withEvent:] + 458
    12  UIKit                               0x007760d1 -[UIWindow _sendTouchesForEvent:] + 567
    13  UIKit                               0x0075737a -[UIApplication sendEvent:] + 447
    14  UIKit                               0x0075c732 _UIApplicationHandleEvent + 7576
    15  GraphicsServices                    0x01c83a36 PurpleEventCallback + 1550
    16  CoreFoundation                      0x0172c064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    17  CoreFoundation                      0x0168c6f7 __CFRunLoopDoSource1 + 215
    18  CoreFoundation                      0x01689983 __CFRunLoopRun + 979
    19  CoreFoundation                      0x01689240 CFRunLoopRunSpecific + 208
    20  CoreFoundation                      0x01689161 CFRunLoopRunInMode + 97
    21  GraphicsServices                    0x01c82268 GSEventRunModal + 217
    22  GraphicsServices                    0x01c8232d GSEventRun + 115
    23  UIKit                               0x0076042e UIApplicationMain + 1160

    26  ???                                 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException' 
  • 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-06-17T13:07:47+00:00Added an answer on June 17, 2026 at 1:07 pm

    Try this code :

    - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
      [tableView beginUpdates];    
      if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Do whatever data deletion you need to do...
      [self.productItems removeObjectAtIndex:indexPath.row];
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationRight ];      
      }       
      [tableView endUpdates];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the error below from the following code: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
I have got the following code: - (void)tableView:(UITableView *)tableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
During swype deleting (most importatnt lines of this method): - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath
So I have this code to delete a row in my tableview: - (void)tableView:(UITableView
This is my code to delete a cell in my UITableView: - (void)tableView:(UITableView *)tableView
my app crashes when the user tries to delete a row from the UITableView
Can I run mysql delete row remotely from other machine? Something alike mysqldump which
i want to Delete row of unbound data from dataGridView1? I made this code,
I am trying to delete some rows from UITableView and here is my code...
I have a UITableView With Two Sections. First section has one row and the

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.