Ankit Sachan
Ankit Sachan

Reputation: 7850

UITableView: Application crashing in attempt of deleting a row

Can any body tell me how can I achieve this. I want to delete a row from tableview with animation. Here goes my sample code

    [section0ARR removeObjectAtIndex:row];
    NSIndexPath *index = [NSIndexPath indexPathForRow:section inSection:row];
    [myTableVEW beginUpdates];
    [myTableVEW deleteRowsAtIndexPaths:[NSArray arrayWithObject:index]    withRowAnimation:UITableViewRowAnimationFade];

    [myTableVEW endUpdates];

Application crashes while attempting this with this assertion Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-1912.3/UITableView.m:1046

but things work perfectly fine if I simply reload my table but in that case animation is not visible.

Here is a checklist

  1. removed item from datasource
    1. deleted row from tableview with animation

please help me to get rid of the crash.

Regards Ankit

Upvotes: 1

Views: 887

Answers (1)

lnafziger
lnafziger

Reputation: 25740

Try changing:

 NSIndexPath *index = [NSIndexPath indexPathForRow:section inSection:row];

To this:

 NSIndexPath *index = [NSIndexPath indexPathForRow:row inSection:section];

(I'm assuming that row and section are valid values since we don't have the rest of the code.)

Upvotes: 1

Related Questions