im working on simple iOS app and there's a reason why I have to use init() section - I just removed everything else for simplification:
import SwiftUI
struct ContentView: View {
@State var newName: String
@Environment(\.colorScheme) private var colorScheme: ColorScheme
init(){
newName = "test"
}
var body: some View{
VStack(alignment: .center) {
TextField("Sample TextField", text: $newName)
}
}
}
everything works just fine until I add @Environment(\.colorScheme) private var colorScheme: ColorScheme
I instantly get quite strange error
Variable 'self.newName' used before being initialized
what am I missing?