Your First iOS & SwiftUI App: An App from Scratch, Episode 12: SwiftUI State | raywenderlich.com

Learn about an important concept called SwiftUI state, which helps you keep your user interface and app state always consistent.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/28797163-your-first-ios-swiftui-app-an-app-from-scratch/lessons/12

the copy code has more variables from down course, so i had to comment out with extreme prejudice

Hi Ray, Im not sure how to write the code with the updated description. When I replace your code with the one provided, i get the error “game is not in scope”. can i please get some help on this?

I’m not sure what code to comment out. I try to comment out all the code that says game and I still get errors. I need help. Anyone knows how to properly code this? When i use Ray’s exact code in the video I get error and the .alert does not auto-complete like Ray’s code does. Please help.

I used the code as indicated in the video from Ray and it works/compiles fine without any warnings. The updated “Copy” code version appears to be from later in the course and raises errors as gjatt and morpheus77 have indicated.

@rwenderlich Would appreciate your help on this!

Hi all,

I’ve updated the author notes, adding an iOS-15-only version of the alert code representing the state of the project at the end of this episode. I’ve also left the final version of the code in these notes, that represents what will result if you keep using that alert modifier throughout the course.

If you have any more questions, please let me know!

Is there a code snippet or video instruction on how to complete topics discussed in this lesson for users targeting iOS 15? The code snippet in lesson 12 shows the state of the project at the end of that episode and what it will look like at the end of this course. If I copy and paste that at lesson 16 I will get errors due to missing material that will not be covered until future videos… 2/12/22 I have now finished this course and am still getting errors from the copied code provided in author notes. Keywords in this copied code have also not been covered in this course. I feel that I wasn’t able to fully follow along after the lesson 12 video.

Everything in this course still works for iOS 15. At some point, Apple will possibly require that you switch away from using the Alert type, but we don’t know when or if.

I’ve added one more intermediate step to the code, and a better description, in the author notes. Let me know if that doesn’t clear things up!

Thank you, jessycatterwaul. This has now helped clear confusion mentioned previously.

1 Like