Chapter 6. The button app, explained

 

This chapter covers

  • Explaining the button app you created in chapter 5
  • Accessing Apple’s documentation
  • Learning to comment (appropriately!)

In chapter 5, you created the My Button App with a button and a label, and you added code to change the title of the button when the user taps it. This chapter will explain what you did and why you did it. Additionally, we’re going to walk through the Apple documentation so you know where to go when you want more information on topics. We’ll also learn to add comments to the code so you’ll remember what you did and why you did it when you look back at your code at a later date.

6.1. The button, explained

To refresh your memory, here are the steps you took in chapter 5:

  1. Starting a new project using the Single View Application template
  2. Adding a button and label to the storyboard, and running the app to test it
  3. Connecting the button and the label to the code (wiring them up using an outlet and an action), and running the app to test it
  4. Adding code to change the text on the label, and running the app to test it
  5. Changing how the label looks by changing the attributes, and running the app to test it

6.1.1. Creating outlets (or “How do I contact Butch?”)

6.2. Documentation

6.3. Commenting: you can never be too wordy, can you?

6.4. Summary