In Xcode 11 Beta 4, I'm no longer able to pass `Binding`s down a view hierarchy. For example, imagine I have a list view called `CoolListView`, which renders multiple `CoolListRow` subviews, and the user is able to change a value from the list superview level that I'd like to percolate down to and update the row subviews:
public struct CoolListRow : View {
@Binding var currentStep: Int
public var body: some View {
// ...
}
public init(currentStep: Binding<Int>) {
self.$currentStep = currentStep
}
}
In Beta 3 and earlier, I would be able to pass this `Binding` as an argument to my subviews, but now in Beta 4, Xcode complains `Cannot assign to property: '$currentStep' is immutable`. Any ideas on how to resolve this?
For those in the same situation, I've just figured out the answer – replace the property wrapper prefix with a type update in your variable declaration:
public struct CoolListRow : View {
var currentStep: Binding<Int>
public var body: some View {
// ...
}
public init(currentStep: Binding<Int>) {
self.currentStep = currentStep
}
}