Can't get the WhyNotTry app to run properly

I've written the code exactly the way the tutorial explained. Word for word. The tutorial states to write @State var selected = "Bowling" but that doesn't work. I asked for help before but no one replied. So I thought I would post again with the code.

  • You posted a screenshot, not the code (as text). Please post the code itself or (better) the link to the tutorial.

Add a Comment

Replies

Change as:

@State var selected = "Bowling"

It does work OK. Maybe there is a mistake in the tutorial (please send the link).

The point to note: a var cannot be changed inside the struct. It is an argument that is passed. To have a changeable var, it should be a @State or @Binding.