Код: Выделить всё
'NSInternalInconsistencyException', reason: 'attempt to delete item 1 from section 1 which only contains 1 items before the update'
func deleteExpense(_ expense: Expense) async throws {
guard let expenseId = expense.id else {
throw ExpenseError.invalidExpenseId
}
try await supabaseClient
.from("expenses")
.delete()
.eq("id", value: expenseId)
.execute()
// Find the index of the budget with the matching ID
guard let index = budgets.firstIndex(where: { $0.id == expense.budgetId }) else {
throw BudgetError.invalidBudgetId
}
budgets[index].expenses = budgets[index].expenses?.filter { $0.id != expenseId }
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... rom-a-list
Мобильная версия