I'm just delving into SwiftUI, and I'm trying to set up my first binding. My Swift formatting style includes always using self. to refer to properties, but it seems I can't do that for bindings:
struct
OpenLocationView : View
{
@State private var location: String = "https://"
var body: some View
{
VStack
{
TextField("Location:", text: $self.location)
^~~~~
// OpenLocationController.swift:33:33: error: use of unresolved identifier '$self'
}
}
}
Writing this as $location seems to compile fine.
Clearly I'm misunderstanding something about the $ syntax. Is this particular issue explained anywhere? Thanks!
That's not really something you can find without knowing about it a-priori. Imagine someone learning SwiftUI, coming across an example that shows a binding. This person might search for âSwiftUI Bindingâ and find this document, but that has no link to a higher-level conceptual document, or a usage document, or even the bindings proposal document.