Я не могу понять, почему мой tableView не обновляется после нажатия кнопки удаления.
Как только я нажимаю на нее, табличное представление "зависает". Если я щелкну другую строку, чтобы табличное представление перешло на другой уровень иерархии, и щелкнул назад, я вижу, что элемент был удален, и все работает нормально.
Вот мой код:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
//[tableView beginUpdates];
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// Do whatever data deletion you need to do...
[tableView beginUpdates];
NSManagedObject *obj = (NSManagedObject *)[entityArray objectAtIndex:indexPath.row];
[managedObjectContext deleteObject:obj];
NSError *error;
[managedObjectContext save:&error];
// Delete the row from the data source
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath, nil] withRowAnimation:YES];
[self viewWillAppear:YES];
}
//[tableView endUpdates];
}
Любой вклад по этой проблеме будет оценен.
Спасибо.