This project was a last chance to review the fundamentals of SwiftUI before we move on to greater things with the next app. Still, we managed to cover some useful new things, not least
UITextChecker, and more, and you have another app you can extend if you want to.
One thing I want to pick out before we finish is my use of
fatalError(). If you read code from my own projects on GitHub, or read some of my more advanced tutorials, you’ll see that I rely on
fatalError() a lot as a way of forcing code to shut down when something impossible has happened. The key to this technique – the thing that stops it from being recklessly dangerous – is knowing when a specific condition ought to be impossible. That comes with time and practice: there is no one quick list of all the places it’s a good idea to use
fatalError(), and instead you’ll figure it out with experience.
Anyone can sit through a tutorial, but it takes actual work to remember what was taught. It’s my job to make sure you take as much from these tutorials as possible, so I’ve prepared a short review to help you check your learning.
One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try extending this app to make sure you fully understand what’s going on:
startGame(), so users can restart with a new word whenever they want to.
Hacking with Swift+ subscribers can get a complete video solution for this checkpoint here: Solution to Word Scramble. If you don’t already subscribe, you can start a free trial today.
SPONSORED Fernando's book will guide you in fixing bugs in three real, open-source, downloadable apps from the App Store. Learn applied programming fundamentals by refactoring real code from published apps. Hacking with Swift readers get a $10 discount!
Link copied to your pasteboard.