23 Nov 2008, 19:39
Generic-user-small

Toby Ambrose (3 posts)

I’m struggling getting past this one, hopefully someone might be able to help. When I click the Delete button for an ingredient the app crashes in the commitEditingSytle method this line:

[tv deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationLeft];

with the following output in the console:

2008-11-23 12:24:46.526 Recipes[20367:20b] *** 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 must be equal to the number of rows contained in that section before the update, plus or minus the number of rows added or removed from that section.'

I’ve diffed my code with the project code several times. From the error is leads me to think that something may not be configured right in IB but I’m not sure what. I’ve double checked the table view has it’s delegate property linked to the File’s Owner. I’m officially stumped. :-)

23 Nov 2008, 21:47
Generic-user-small

Toby Ambrose (3 posts)

Not entirely sure I understand this, but I managed to eliminate the crash, so I’m back on track. I apparently missed changing the ingredient arrays to mutable ones (screencast 3). So, from the error I posted, it seems the call to remove an ingredient failed. Then the post-delete number of rows for the table did not equal the original number minus the number removed.

Given that though, shouldn’t the screencast example with the following stub have failed too?

- (void)removeIngredient:(NSString *)ingredient forRecipe:(NSString *)recipe {
}

In that case, wouldn’t there be fewer rows in the tableView than the ingredients array and shouldn’t that cause the same error I was seeing?

01 Jan 2009, 15:21
Generic-user-small

Blake Bowling (3 posts)

I have the exact same problem… but im venturing off the videos and incorporating sections into the list.. and mine is crashing (with the same error) at

- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView{

very strange to me as the testing I have it setup, the number of sections isnt changing. I have tried a dynamic as well as a static return.

if anyone has any brilliant ideas, please let me know.

03 Jan 2009, 20:52
Generic-user-small

Matthew (1 post)

I had this problem with Pragmatic iPhone Tutorial 4:

2009-01-03 20:26:25.683 Receipes[33856:20b] ** Assertion failure in -[UITableView _endCellAnimations], /SourceCache/UIKit/UIKit-747.36.52/UITableView.m:679 2009-01-03 20:26:25.683 Receipes[33856:20b] ** 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 must be equal to the number of rows contained in that section before the update, plus or minus the number of rows added or removed from that section.’ 2009-01-03 20:26:25.684 Receipes[33856:20b] Stack:

I searched on Google and found this and other posts. After reading these I ran the code against Simulator 2.1 and all was fine. My Phone is running 2.2 and I have been simulating 2.2 for the last hour.

Any help on explaining this would be appreciated.

15 Jan 2009, 21:04
Eyes_pragsmall

Matt (2 posts)

I also have the same issue as Matthew. The error occurs under 2.2 but not 2.1. Any suggestions would be really helpful.

15 Jan 2009, 21:21
Eyes_pragsmall

Matt (2 posts)

This does work once the code to remove an ingredient has been completed… which in retrospect I probably should have realised from the error message:

bq. 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 must be equal to the number of rows contained in that section before the update, plus or minus the number of rows added or removed from that section.’

Sorry for the noise!

19 Jan 2009, 01:23
Generic-user-small

Eric (1 post)

I fixed this issue by adding the last line to the following function in the RecipesAppDelegate:

@- (void)addIngredient:(NSString)ingredientName forRecipe:(NSString)recipeName { [[data valueForKey:recipeName] addObject:ingredientName]; ingredientsController.ingredients = [self ingredientsForRecipe:recipeName]; }@

  You must be logged in to comment