ios - When I try to remove a UITableViewCell, I get this error: Invalid update: invalid number of rows in section 0, but I can't seem to fix it -
i have gesture on uitableviewcell subclass called articlecell, when swiped method in uitableviewcontroller class gets called delete cell swiped.
the delegate method looks this:
- (void)swipedtoremovecell:(articlecell *)articlecell { nsindexpath *indexpath = [self.tableview indexpathforcell:articlecell]; [self.tableview beginupdates]; [self.tableview deleterowsatindexpaths:@[indexpath] withrowanimation:uitableviewrowanimationautomatic]; [self.tableview endupdates]; [self.tableview reloaddata]; }
but every time swipe, error:
invalid update: invalid number of rows in section 0
more information: uses core data data source, uses nsfetchedresultscontroller. have update there? (i haven't touched of methods.)
you need remove row data source object well. need remove core data store @ same time delete row representing data table view itself.
the issue mismatch, remove row table view -numberofrowsintableview
data source method still returning old number of rows because fetched results controller still sees number in data store.
Comments
Post a Comment