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

**URL:** <https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836>\
**Category:** 🎓 Courses & Articles\
**Created:** [January 11, 2022, 3:20am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836 "2022-01-11T03:20:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![rwenderlich](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/rwenderlich/32/108604_2.png) [@rwenderlich](https://forums.kodeco.com/u/rwenderlich)\
**Post date:** [January 11, 2022, 3:20am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/1 "2022-01-11T03:20:37Z")

</div>

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](https://www.raywenderlich.com/28797163-your-first-ios-swiftui-app-an-app-from-scratch/lessons/12)

---

<div class="post-metadata">

**Author:** ![caflatlander](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caflatlander/32/102235_2.png) [@caflatlander](https://forums.kodeco.com/u/caflatlander)\
**Post date:** [January 14, 2022, 4:49pm UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/2 "2022-01-14T16:49:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gjatt](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gjatt/32/102075_2.png) [@gjatt](https://forums.kodeco.com/u/gjatt)\
**Post date:** [January 19, 2022, 4:36am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/3 "2022-01-19T04:36:30Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![morpheus77](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/morpheus77/32/102075_2.png) [@morpheus77](https://forums.kodeco.com/u/morpheus77)\
**Post date:** [January 20, 2022, 12:54am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/4 "2022-01-20T00:54:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dbadev](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dbadev/32/102075_2.png) [@dbadev](https://forums.kodeco.com/u/dbadev)\
**Post date:** [January 23, 2022, 9:59pm UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/5 "2022-01-23T21:59:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dudem0n](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/dudem0n/32/102075_2.png) [@dudem0n](https://forums.kodeco.com/u/dudem0n)\
**Post date:** [January 24, 2022, 3:57am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/6 "2022-01-24T03:57:39Z")

</div>

@rwenderlich Would appreciate your help on this!

---

<div class="post-metadata">

**Author:** ![jessycatterwaul](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jessycatterwaul/32/110937_2.png) [@jessycatterwaul](https://forums.kodeco.com/u/jessycatterwaul)\
**Post date:** [January 28, 2022, 11:38pm UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/7 "2022-01-28T23:38:08Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![gpeters1156](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gpeters1156/32/102075_2.png) [@gpeters1156](https://forums.kodeco.com/u/gpeters1156)\
**Post date:** [February 12, 2022, 12:46pm UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/8 "2022-02-12T12:46:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jessycatterwaul](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/jessycatterwaul/32/110937_2.png) [@jessycatterwaul](https://forums.kodeco.com/u/jessycatterwaul)\
**Post date:** [February 14, 2022, 4:52am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/9 "2022-02-14T04:52:57Z")

</div>

> [@gpeters1156](#):
>
> Is there a code snippet or video instruction on how to complete topics discussed in this lesson for users targeting iOS 15?
> 
> …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.

> [@gpeters1156](#):
>
> 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’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!

---

<div class="post-metadata">

**Author:** ![gpeters1156](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/gpeters1156/32/102075_2.png) [@gpeters1156](https://forums.kodeco.com/u/gpeters1156)\
**Post date:** [February 14, 2022, 11:53am UTC](https://forums.kodeco.com/t/your-first-ios-swiftui-app-an-app-from-scratch-episode-12-swiftui-state-raywenderlich-com/161836/10 "2022-02-14T11:53:23Z")

</div>

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