Skip to main content

Day 31

About 2 minSwiftcrashcoursepaul-hudsonswiftswiftuihacking-with-swiftxcodeappstore

Day 31 ๊ด€๋ จ


100 Days of SwiftUI - Day 31

Project 5, part 3

Project 5, part 3

Dwayne โ€œThe Rockโ€ Johnson once said, โ€œsuccess isn't always about greatness, it's about consistency. Consistent hard work leads to success; greatness will come.โ€

Obviously I want to get you towards SwiftUI greatness as fast and effectively as possible, but that takes a lot of consistency from you. To be fair, it is already day 31 and you keep coming back, so youโ€™re fulfilling your part of the deal โ€“ well done!

With another project done, itโ€™s time for you to take matters into your own hands. Yes, this is the โ€œhard workโ€ part of the project, where you need to complete some challenges without my help, and also pass a test to make sure what youโ€™re learning is sinking in.

You can do this!

Today you should work through the wrap up chapter for project 5, complete its review, then work through all three of its challenges.

Word Scramble: Wrap up

Word Scramble: Wrap up
100 Days of SwiftUI - Day 31 - Word Scramble: Wrap up

Word Scramble: Wrap up

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 List, onAppear, Bundle, fatalError(), 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.

Review what you learned

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.

Click here to review what you learned in this project.open in new window

Challenge

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:

  1. Disallow answers that are shorter than three letters or are just our start word.
  2. Add a toolbar button that calls startGame(), so users can restart with a new word whenever they want to.
  3. Put a text view somewhere so you can track and show the playerโ€™s score for a given root word. How you calculate score is down to you, but something involving number of words and their letter count would be reasonable.

Why not make a video of your finished app and share it online? You should be proud of all your hard work!


์ด์ฐฌํฌ (MarkiiimarK)
Never Stop Learning.