error appears when i try to put navigation link inside button code
Button("back") {
NavigationLink(destination: ContentView())
}
^
Post
Replies
Boosts
Views
Activity
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?