Shawn_Rong Shawn_Rong - 4 months ago 77
Objective-C Question

Assertion failure when delete rows in UITableView

When I delete row in tableview,I am getting the following exception:

*** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.60.7/UITableView.m:1716


And here's part of my code:

[self.feedListView.tableView beginUpdates];
[self.feedListView.tableView deleteRowsAtIndexPaths:@[ atIndexPath ] withRowAnimation:UITableViewRowAnimationFade];
[self.feedListView.tableView endUpdates];


And a screenshot:

enter image description here

Any help is appreciated.

Thanks

Answer

You need to remove feedToDelete from self.allFeeds:

[self.feedListView.tableView beginUpdates];
NSMutableArray *array = [self.allFeeds mutableCopy];
[array removeObject:feedToDelete];
self.allFeeds = array;
[self.feedListView.tableView deleteRowsAtIndexPaths:@[ atIndexPath ] withRowAnimation:UITableViewRowAnimationFade];
[self.feedListView.tableView endUpdates];
Comments