Join Todd Perkins for an in-depth discussion in this video Try it: What's for lunch?, part of Teaching iOS Programming to Kids.
Before we write our code, let's take a tour of our Xcode project. Go in to click the Run button to run the application in the iOS simulator. If your simulator looks larger than mine does, and you want to shrink it down a little bit, you can go to Window>Scale, and change it there. On the screen I see today is: Wednesday, Bob is having nachos. This application is very simple. It shows the current day of the week which, as I am recording this movie, is Wednesday. And it says what is for lunch on that particular day of the week.
I'll go back to Xcode and click the Stop button. In the main.storyboard file, there are two labels on the screen. If I click on them, I'll see that this is referenced as something called Today_Label encode on the top. And the bottom one is called Lunch_Label encode. So these two labels are connected to my code. The code connection is created through the ViewController.H code file. The bulk of the code of our application, all the brains of it, are contained in ViewController.m. I'm going to click the button on the top right of the screen to hide the Utilities view, so I can see the code easier.
Now there's a lot of code in this file. Some of it's important, and some of it is not relevant to the work we're going to be doing throughout this chapter. The only code that you need to be concerned with is that contained in the viewDidLoad block. That block, in my code, starts on line 17 and ends on line 38. The part of that code that explains what the app should do and what should show in the text fields is contained on lines 21 through 37. Right now this code may look like a bunch of words or things that look similar to words but that aren't really words.
But throughout this chapter, my goal is to help you learn what some of these commands mean and how to manipulate them on your own.
- Teacher's Guide: Introduces the concepts in the chapter and preps the adult on places where the student might get stuck
- Try It: Immediately engages the student, showing working code in action
- Check It Out: Encourages the adult and student to engage with and edit some existing code
- The Facts: A lecture for the student to watch
- Extend It: An exploration of expanded and extended concepts
- Challenge: A hands-on coding challenge for the student
- Solution: A step-by-step solution presented by the author
This course is designed to help you, an expert, help a beginner learn about the code, logic, and interface elements that lie behind iOS apps and games. The structured curriculum supports those who have a solid understanding of the iOS SDK, but don't necessarily know how to teach it effectively to kids.