I have this List
view
List(expenses) { expense in
ExpenseListItemView(expense: expense)
.swipeActions {
Button("Edit") {
selectedExpenseId = expense.id
showAddExpensePopup = true
}.tint(.blue)
}
}
.popover(isPresented: $showExpenseEditorPopup) {
if let id = selectedExpenseId {
ExpenseEditorScreen(expenseId: id)
} else {
ExpenseEditorScreen()
}
}
}
selectedExpenseId
and showAddExpensePopup
are both @State
variables and selectedExpenseId
is not getting updated and so I am always in the else case in the popover and can't edit an existing object
I know I can achieve this functionality by using the other .popover(item: )
, I just want to understand what's happening in this case