У меня проблема при попытке удалить строки из моего UITableView: UITableView получает количество строк из NSMutableArray:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [alertsArray count];
}
Я добавляю объекты в NSMutableArray следующим образом:
- (void)saveButton:(id)sender {
[alertsArray addObject:
[self.tableView reloadData];
}
С помощью этого кода я разрешаю удалять строки:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the row from the data source.
[self.tableView deleteRowsAtIndexPaths:[NSMutableArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[alertsArray removeObjectAtIndex:indexPath.row];
[tableView reloadData];
}
else if (editingStyle == UITableViewCellEditingStyleInsert) {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
}
}
По какой-то причине при попытке удаления строк происходит сбой приложения.
Спасибо!