100 Days of SwiftUI
2026-05-18
Project 5, part 2
I promise to stop at the end of today’s lesson 🙃
Adding to a list of words
- to begin with, just collect the list of words they enter — later we’ll add validation
.onSubmit()is a modifier on theListthat runs a method- it takes no parameters (save the name of the
func) and returns nothing - keyboard
ReturnorEnterwill trigger it, so no need for a button
- it takes no parameters (save the name of the
- auto-capitalization (and auto-correct!) can be disabled on
TextFields withAnimationwhen the wordlist is modified is a nice little touch
Running code when our app launches
- creating a
functhat will load the main word list (a text file)- it will see if it’s there
- it will see if it’s valid
- if not it will send a
fatalError()message
- a modifier on the
List(.onAppear(perform: startGame)) will cause thefuncto run when the view appears (i.e. when we see the screen of the app)
Tip
The placement of the view modifiers is really important! I had them on the NavigationStack but never saw the word to search. When I moved them to the List it worked as expected