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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:33:18+00:00 2026-05-16T17:33:18+00:00

I have a sectioned UITableView using dictionaries adapting code from a tutorial (I don’t

  • 0

I have a sectioned UITableView using dictionaries adapting code from a tutorial (I don’t have a link on me at the moment but I can dig it up if you really need it).

Anyway I’m trying to have it delete an item from the list when I get this error (warning: its long)

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 (2) must be equal to the number of rows contained in that section before the update (2), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted).

I Kind of get the information about the number of rows but I’m nut sure how to fix this.

If you want to see the debugger information I paste-binned it because its so long: http://pastebin.com/0difSEnM

Here’s my code:

-(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)index {
 NSDictionary *dictionary = [data objectAtIndex:index.section];
 NSMutableArray *array = [NSMutableArray arrayWithArray:[dictionary objectForKey:@"My Wishlists"]];
 NSString *selectedWishlist = [array objectAtIndex:index.row];
 //now remove the item
[array removeObjectAtIndex:index.row];
 [data removeObjectAtIndex:index.section];
 NSDictionary *newdictionary = [NSDictionary dictionaryWithObject:[NSArray arrayWithArray:array] forKey:@"My Wishlists"];
 [data insertObject:newdictionary atIndex:0];
// [data addObject:newdictionary];
 [mainTableView reloadData]; // tried without and with this, no difference
 [mainTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:index] withRowAnimation:UITableViewRowAnimationTop];
}

Thanks!
Christian Stewart

  • 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-16T17:33:19+00:00Added an answer on May 16, 2026 at 5:33 pm

    Looks like this is your problem:

    [data insertObject:newdictionary atIndex:0];
    

    From the docs for NSMutableArray’s insertObject:atIndex::

    Discussion If index is already
    occupied, the objects at index and
    beyond are shifted by adding 1 to
    their indices to make room.

    Try using replaceObjectAtIndex:withObject: instead.

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

Sidebar

Related Questions

I have a sectioned UITableView with 3 categories. I'm using this code: NSArray *arrayOne
I am using the following code to edit a uitableview, but i'd like only
I have created a UITableView in an app, using the basis of a tutorial
So I have a UITableView that I'm using with Section Index Titles.. but I'm
I have an warning while returning an NSInteger. I am using UITableView's inbuilt method
I have a UITableView inside of a View created from a NIB. the table
I have set up a UITableView with 3 sections that pulls from 3 NSArrays
I have a UITableview made up with a custom cell loaded from a nib.
I have problems using this UITableView method : - (void)deleteSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation First the
I have a simple table view which I have built using an example from

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.