Post

Replies

Boosts

Views

Activity

Cannot declare local wrapped variable in result builder
I'm trying to change the view without using NavigationLink because it has the bar on top See this: https://developer.apple.com/forums/thread/667742 This is my code: struct ContentView: View {   var body: some View {     @State var another = false     if (another) {       AnotherView()     } else {       ContentView()     }   } I get an error: Cannot declare local wrapped variable in result builder. @State var another = false struct ContentView: View {   var body: some View {     if (another) {       AnotherView()     } else {       ContentView()     }   } Now: Property wrappers are not yet supported in top-level code. Where do i put the variable and the logic?
1
0
2.6k
Sep ’22