I read all the posts related to this and I still have an error:
'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (5) must be equal to the number of rows contained in that section before the update (5), plus or minus the number of rows inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).'
Here are the details:
in .h I have an NSMutableArray :
@property (strong,nonatomic) NSMutableArray *currentCart;
In .m my numberOfRowsInSection looks like this:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
To enable deletion and deletion of an object from an array:
// Editing of rows is enabled - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { //when delete is tapped [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; [currentCart removeObjectAtIndex:indexPath.row]; } }
I thought that if the number of my partitions depends on the amount of array I am editing, will it provide the correct number of rows? Can you do this without reloading the table when you delete the row anyway?
arrays ios objective-c nsmutablearray
user3085646 Feb 19 '14 at 3:54 a.m. 2014-02-19 03:54
source share