Post

Replies

Boosts

Views

Activity

TextField gives error message
It is driving me crazy, because I really don't know what I am doing wrong. I have a observable class: @Observable class Variables: Identifiable { var id: UUID() var xValue: Int = 1 var yValue: Int = 1 } And a main view that calls a Subview to set the variables, using environment to set variables to the Subview, because this is a very simplified code example and in the final code lot more subview are gonna use this data. struct MainView: View { @State var vars = Variables() var body: Some View { VStack { Subview() .environment(vars) .padding() Text("Value X = \($vars.xValue)") Text("Value Y = \($vars.yValue)") } } struct Subview: View { @Environment(Variables.self) private var vars var body: Some View { VStack { TextField("xValue", value $vars.xValue, format: .number) { Text("X") } TextField("yValue", value $vars.yValue, format: .number) { Text("Y") } } } I Get this error for the TextFields: Cannot convert value of type 'Int' to expected argument type 'Binding' I just don't get it. Am I mixing up different kind of bindings, is something wrong in the definition of TextField.......................................... Please help me.
2
0
442
Apr ’24
Very annoying warnings using XCode and SwiftUI
I recently changed my old ancient MacBookPro for a MBAir 15" M2., mainly to upgrade Xcode and Swift to SwiftUI. But using Xcode 15.1, trying to update the preview, or trying to run the code I get bombarded by these warnings: managedappdistributiond unexpectedly quit findmylocated unexpectedly quit aegirposter unexpectedly quit. The warnings are so frequent that it stops me programming. Mind, I'm not a professional programmer, rather a very driven amateur, but I don't think this this is what is meant by offering a great API. Can someone please help me get rid off all this irritating stuff.
17
10
2.2k
Dec ’23
Why is every example in documentation obj-c
I’m trying to understand the basics of a lot of user-interface (cocoa) workings, but get really frustrated by the documentation. I started coding in swift and NEVER used obj-c in my life. However, all code examples are in obj-c. I understand that there are still Some people using it , but nowadays the majority doensn’t anymore. Please update you’re documentation into something readable for people like me. I know I’m absolutely not the only one trying to figure out what cryptic message is written in obj-c in the documentation. it seems like a small thing for a company that rich as Apple to keep up-to-date. thank you, Leo
1
0
444
Aug ’23