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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:00:42+00:00 2026-06-13T10:00:42+00:00

My tableview uses in-place editing and adding. A new row is added when the

  • 0

My tableview uses in-place editing and adding. A new row is added when the edit button is pushed and this new row can be edited and commited. When commiting the new row into the tableview, the new row is added and the blank cell is moved down which can subsequently be edited and another row added again. However when attempting to add another row during the same editing session I get an error:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', 
reason: 'attempt to insert row 2 into section 0, but there are only 2 rows in section 0 after the update'

I was getting this error before when adding only a single row but after following a tutorial on in-place editing I thought I had it solved. Here are some relevant methods:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    int count = [items count];
    if(self.editing)count++;
    return count;

}



- (void)setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing:editing animated:animated];

    [keyphraseTextField setEnabled:YES];

    NSArray *paths = [NSArray arrayWithObject:
                      [NSIndexPath indexPathForRow:[items count] inSection:0]];
    if (editing)
    {
        [[self tableView] insertRowsAtIndexPaths:paths
                                withRowAnimation:UITableViewRowAnimationTop];
    }
    else {
        [[self tableView] deleteRowsAtIndexPaths:paths
                                withRowAnimation:UITableViewRowAnimationTop];
    }
}



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

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        [self deleteItemAtIndexPath:indexPath];

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

    }

    else if (editingStyle == UITableViewCellEditingStyleInsert) {

        NSIndexPath *thePath = [NSIndexPath indexPathForRow:[items count] inSection:0];

        DBAccess *dbaccess = [[DBAccess alloc] init];

        NSInteger keyphraseCount = [dbaccess getDomainKeyphraseCount:domain_id];
        NSInteger keyphraseCountLimit = [dbaccess getDomainKeyphraseCountLimit:domain_id];

        [dbaccess closeDatabase];

        [dbaccess release];

        if(![keyphraseTextField.text isEqualToString:@""] && keyphraseCount<keyphraseCountLimit){

            [self insertItemAtIndexPath:thePath];

            [self readItems];

            [self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:thePath] withRowAnimation:UITableViewRowAnimationLeft];

            [self makeNSURLConnection];

        }else{

            if([keyphraseTextField.text isEqualToString:@""]){
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Please insert Keyphrase." delegate:self cancelButtonTitle:@"Not Now." otherButtonTitles:@"Upgrade!", nil];
                [alert setTag:10];
                [alert show];
                [alert release];
            }
            if(keyphraseCount>=keyphraseCountLimit){
                UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Kindly upgrade your subscription to add more keyphrases!" delegate:self cancelButtonTitle:@"Not Now." otherButtonTitles:@"Upgrade!", nil];
                [alert setTag:10];
                [alert show];
                [alert release];
            }

        }

    }

}



- (UITableViewCellEditingStyle)tableView:(UITableView *)aTableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {

    if (self.editing == NO || !indexPath) return UITableViewCellEditingStyleNone;

    if (self.editing && indexPath.row == ([items count])) {

        return UITableViewCellEditingStyleInsert;

    } else {

        return UITableViewCellEditingStyleDelete;

    }

    return UITableViewCellEditingStyleNone;

}

How can I resolve this issue so the user is able to add row after row in a single editing “session”?

  • 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-13T10:00:43+00:00Added an answer on June 13, 2026 at 10:00 am

    In the end I had to change a lot and add a manual count for the number of rows in the tablview that was changed after each update. It’s not the way I like to code but it works and I couldn’t work out what was going wrong.

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

Sidebar

Related Questions

I have an app that uses a tableview, along with a UIButton that I
I have a dynamic tableview which has a prototype cell with a button that,
I have a simple questionnaire app that uses tableview. When users answers questions they
What is the best way to implement arbitrary row reordering in a tableview that
I have a TableView controller class that uses a fetched results controller to display
My UITableViewController class uses an .xib. I would like to make the TableView only
I'm developing an iPhone application which uses a TableView to display XML data. The
Is the little blue mail dot the iPhone mail program uses to signify new
I want to update my TableView from the deprecated initWithFrame:reuseIdentifier: . My tableview uses
I have a mac app that uses tableView that has some rows.On taping(single tap

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.