Я получаю эту ошибку, когда пытаюсь загрузить данные в табличное представление.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (73) must be equal to the number of rows contained in that section before the update (71), plus or minus the number of rows inserted or deleted from that section (3 inserted, 0 deleted).
Что может быть не так?
Спасибо
EDIT :
Я инициализирую массив в ViewWillAppear и добавляю новые объекты в тот же массив в методе didSelectRowAtIndexPath
Tableview
Здеськод On viewWillAppear:
cellTextArray = [[NSMutableArray alloc] init];
[cellTextArray addObjectsFromArray:newPosts];
Вот код, который изменяет массив для didSelectRowAtIndexPath:
[cellTextArray addObjectsFromArray:newPosts];
NSMutableArray *insertIndexPaths = [NSMutableArray array];
for (NSUInteger item = count; item < count + newCount; item++) {
[insertIndexPaths addObject:[NSIndexPath indexPathForRow:item
inSection:0]];
}
[self.table beginUpdates];
[self.table insertRowsAtIndexPaths:insertIndexPaths
withRowAnimation:UITableViewRowAnimationFade];
[self.table endUpdates];
[self.table scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionNone
animated:YES];
NSIndexPath *selected = [self.table indexPathForSelectedRow];
if (selected) {
[self.table deselectRowAtIndexPath:selected animated:YES];
}
Здесь newPosts - это массив, который имеет значения, которые добавляются к cellTextArray в методе didSelectRowAtIndexPath и методе viewWillAppear.