Day 38
Day 38 ๊ด๋ จ
Project 8, part three
There are many well-known quotes from Shakespeare, but thereโs one I think is particularly apt today: โthe fool doth think he is wise, but the wise man knows himself to be a fool.โ I donโt know where youโd rank yourself in terms of Auto Layout knowledge, but I hope youโre at least aware that itโs a really big, complex space to work in!
In my talk at NSSpain 2018 I said โAuto Layout makes hard things easy, and easy things hardโ โ youโll find you can do relatively advanced layouts like todayโs in about an hour, but occasionally youโll find yourself wanting one specific layout constraint that is really hard to get right.
Fortunately for all of us, this part of your Auto Layout learning is complete, so itโs time for us to review what youโve learned.
Today you should work through the wrap up chapter for project 8, complete its review, then work through all three of its challenges.
Wrap up
Wrap up
Yes, it took quite a lot of user interface code to get this project going, but I hope it has shown you that you can make some great games using just the UIKit tools you already know. Building user interfaces programmatically is obviously much less visual than using storyboards, but the flip side is that everything is under your control โ there are no connections happening behind the scenes.
Of course, at the same time as making another game, you've made several steps forward in your iOS development journey, this time learning about addTarget()
, enumerated()
, joined()
, replacingOccurrences()
, and more.
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 project 8.
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:
- Use the techniques you learned in project 2 to draw a thin gray line around the buttons view, to make it stand out from the rest of the UI.
- If the user enters an incorrect guess, show an alert telling them they are wrong. Youโll need to extend the
submitTapped()
method so that iffirstIndex(of:)
failed to find the guess you show the alert. - Try making the game also deduct points if the player makes an incorrect guess. Think about how you can move to the next level โ we canโt use a simple division remainder on the playerโs
score
any more, because they might have lost some points.
Wrap up - Additional
Once youโre done, tell other people: youโve built another great app for iOS, and youโve learned how to build a complete user interface entirely in code.
You should be proud of what youโve accomplished โ keep it up!