I am trying to crate a regular class function that takes an optional Binding<Bool> as a parameter. The idea is that the function will modify the boolean to disable/enable a SwitUI View without the need for callback blocks.
The problem is that I can't find the proper way to modify the boolean from within the function.
func executeTask(inProgress: Binding<Bool>? = nil)
{
inProgress = true // Error
// ...
inProgress = false // Error
}
The error:
Cannot assign to value: 'inProgress' is a 'let' constant
I also tried to mimic SwiftUI behavior by creating a @Binding var inProgress: Bool in the class, assign it, and then modify it with no luck.
Also I would be OK with a non-optional 'inProgress' if that helps, but so far it doesn't.