SwiftUI binding: A very simple trick
Binding is a fundamental concept for SWIFTUI. According to Apple documentation: Use a binding to create a two-way connection between a view and its underlying model. For example, you can create a binding between a Toggle and a Bool property of a State. Interacting with the toggle control changes the value of the Bool, and mutating the value of the Bool causes the toggle to update its presented state. You can get a binding from a State by accessing its binding property. You can also use the $ prefix operator with any property of a State to create a binding. One of the initializers of Binding is: init(get: @escaping () -> Value, set: @escaping (Value) -> Void) In this post, I will show you 2 very useful utilisations of this initializer, that will make your life easier. Binding to an array : Prior to beta4 of Xcode 11, it was fairly simple to bind a list of controls to elements of an array. However, in beta5, if you are using this, you will get a warning: subscript(...