The accident happens because you need to reset the number if the number of lines in is -
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [tempArray count]; }
In one case, a flag variable is used, as shown below:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if (deleting) return rowcount; else return [tempArray count]; }
You also need to change the delete code as shown below:
deleting = YES; for (i = [uiTable numberOfRowsInSection:0] - 1; i >=0 ; i--) { NSIndexPath *index = [NSIndexPath indexPathForRow:i inSection:0]; [uiTable deleteRowsAtIndexPaths:[NSArray arrayWithObject:index] withRowAnimation:UITableViewRowAnimationFade]; rowcount = i; } deleting = NO; [uiTable reloadData];
in your .h file
BOOL deleting; NSInteger rowcount;
Hope this helps ...
Ram G.
source share