This was working until beta 7. It seems that when I want to pass one element in a collection as a binding to another view, the preview gets broken
I followed the release notes where it says @Binding no longer conforms to collection protocol comments are at the bottom
I have Catalina and xcode in beta 7
Parent:
struct SimpleStructure {
var label: String
}
struct ContentView: View {
@State private var myVariables = [SimpleStructure(label: "hello")]
var body: some View {
ChildView(myVariables: $myVariables)
}
}
Child
struct ChildView: View {
@Binding var myVariables: [SimpleStructure]
var body: some View {
List(myVariables.indexed(), id: \.1.label) {(index, variable) in
GrandChildView(myVariable: self.$myVariables[index])
}
}
}
GrandChild
struct GrandChildView: View {
@Binding var myVariable:SimpleStructure
var body: some View {
Text(myVariable.label)
}
}
UPDATE:
Still an issue with Beta 8
The release notes have a typo. You need to change:
var endIndex: Index { base.startIndex }
with
var endIndex: Index { base.endIndex }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With