I have a very simple SwiftUI app, works fine on iOS, crashes on macOS:
struct ContentView: View { @State var testStr: String = "" @State var selection: TextSelection? = nil
var body: some View
{
VStack
{
TextField("Test", text: $testStr, selection: $selection)
.onChange(of: selection) {print("selection changed")}
}
.padding()
}
} • Start app, write something in the TextField and move the cursor around. iOS: "selection changed" Mac: nothing (Bug ?)
• double click on some word both Mac and iOS: "selection changed"
• write some more in the TextField iOS: selection changed Mac: crash
Any idea what I am doing wrong?
Gerriet.