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

  • Home
  • SEARCH
  • 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 1115347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T03:08:34+00:00 2026-05-17T03:08:34+00:00

I’ve got a UITableViewController with a bunch of random items in it. I want

  • 0

I’ve got a UITableViewController with a bunch of random items in it. I want to be able to add items to it, and delete items from it. I have a UITextField in the first section header, so you can type in a word/phrase and add it to the list.

You can delete words from the list without issue, however, if you add a word to the list, then try to delete it, the app ends and returns to the home screen; nothing appears in the console.

I’m not sure where the problem lies. Here’s the addNewWord method I’ve been using:

- (void)addNewWord
{
    NSString *newWord = [textField text];
    [array insertObject:newWord atIndex:0];
    NSLog(@"%d", [array count]);
    [textField setText:@""];

    [[self tableView] reloadData];

}

And here is the -(void) tableView:commitEditingStyle:forRowAtIndexPath method

- (void)tableView:(UITableView *)tableView 
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle 
forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        [array removeObjectAtIndex:[indexPath row]];
        [tableView beginUpdates];
        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]
                         withRowAnimation:UITableViewRowAnimationRight];
        [tableView endUpdates];
    }
    NSLog(@"%d", [array count]);
}

That’s all I’ve come up with as to where the problem might be, which is also why I’m stuck.

Any insight is greatly appreciated. Thank you very much!

-Edit: Added [tableView beginUpdates]; and [tableView endUpdates]; same results. Any other ideas?

-Edit2: When I added the [tableView beginUpdates]; and [tableView endUpdates];, I get an exception. Here’s the console output:

2010-09-30 05:56:40.172 DictionaryWordsTest[2350:207] *** Assertion failure in 
-[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/
UIKit-1262.60.3/UITableView.m:920
2010-09-30 05:56:40.175 DictionaryWordsTest[2350:207] *** Terminating app 
due to uncaught exception 'NSInternalInconsistencyException', reason: 
'Invalid update: invalid number of rows in section 0.  The number of rows 
contained in an existing section after the update (17) must be equal to the 
number of rows contained in that section before the update (17), 
plus or minus the number of rows inserted or deleted from that section 
(0 inserted, 1 deleted).'
*** Call stack at first throw:
(
0   CoreFoundation                      0x02486b99 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x025d640e objc_exception_throw + 47
2   CoreFoundation                      0x0243f238 +[NSException raise:format:arguments:] + 136
3   Foundation                          0x000b2e37 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4   UIKit                               0x00332d37 -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 8719
5   UIKit                               0x00322a01 -[UITableView endUpdates] + 42
6   DictionaryWordsTest                 0x00002a73 -[DictionaryViewController tableView:commitEditingStyle:forRowAtIndexPath:] + 140
7   UIKit                               0x0031f96d -[UITableView(UITableViewInternal) animateDeletionOfRowWithCell:] + 101
8   UIKit                               0x002b87f8 -[UIApplication sendAction:to:from:forEvent:] + 119
9   UIKit                               0x00343de0 -[UIControl sendAction:to:forEvent:] + 67
10  UIKit                               0x00346262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
11  UIKit                               0x00344e0f -[UIControl touchesEnded:withEvent:] + 458
12  UIKit                               0x002dc3d0 -[UIWindow _sendTouchesForEvent:] + 567
13  UIKit                               0x002bdcb4 -[UIApplication sendEvent:] + 447
14  UIKit                               0x002c29bf _UIApplicationHandleEvent + 7672
15  GraphicsServices                    0x02d66822 PurpleEventCallback + 1550
16  CoreFoundation                      0x02467ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
17  CoreFoundation                      0x023c8807 __CFRunLoopDoSource1 + 215
18  CoreFoundation                      0x023c5a93 __CFRunLoopRun + 979
19  CoreFoundation                      0x023c5350 CFRunLoopRunSpecific + 208
20  CoreFoundation                      0x023c5271 CFRunLoopRunInMode + 97
21  GraphicsServices                    0x02d6500c GSEventRunModal + 217
22  GraphicsServices                    0x02d650d1 GSEventRun + 115
23  UIKit                               0x002c6af2 UIApplicationMain + 1160
24  DictionaryWordsTest                 0x00001f58 main + 102
25  DictionaryWordsTest                 0x00001ee9 start + 53
)
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-05-17T03:08:34+00:00Added an answer on May 17, 2026 at 3:08 am

    You need to wrap your -[tableView deleteRowsAtIndexPaths] call with [tableView beginUpdates] and [tableView endUpdates].

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

Sidebar

Related Questions

No related questions found

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.