How can I have an optional argument of type Binding<[String]>
in the init function?
@Binding var counter:Int
@Binding var strings:[String]
init(counter:Binding<Int>, strings:Binding<[String]>? ) {
self._counter = counter
self._strings = strings ?? Binding.constant([String]())
}
// creating a new view as follows throws an error
MyView(counter: $counter)
The error I get is:
Missing argument for parameter 'strings' in call