I have the following code:
@State var message: String = ""
var body: some View {
VStack {
ZStack(alignment: .topLeading) {
TextEditor(text: Binding($message))
.frame(minHeight: 30, alignment: .leading)
.cornerRadius(6.0)
.multilineTextAlignment(.leading)
Text(message ?? "Message")
.padding(.leading, 4)
.opacity(message == "" ? 1 : 0)
}
.font(.body)
}
}
}
When I try to execute the code, it says "Cannot convert value of type 'Binding<String?>' to expected argument type 'Binding<String>'" next to TextEditor(text: Binding($message) Why am I getting this error?
Binding(). Just useTextEditor(text: $message)