Chapter 4. I/O laboratory

 

Now we’re going to learn how to make your users and your apps communicate with each other.

This chapter covers

  • Input: how your users communicate with your apps
  • Output: how your app communicates with your users
  • How to get input from a text field and show it as output
  • What to do when things go wrong

You’ve learned how to set up an app. Now that you know the basics, you can create apps that produce output in response to the input your users give them. In this chapter, you focus on input and output. And because you’re going to be adding code to an app, now is a great time to learn how to fix your apps when you make mistakes and break rules.

When you’re done creating apps in this chapter, you’ll know how to get input from your user and display that input on the screen. Lots of steps are involved, so you’ll build your app in chunks. Along the way, I’m going to show you what errors look like on purpose. Don’t worry—I’ll show you how to fix these errors. Here’s what your path looks like:

1.  Build an app that outputs text.

2.  Run the app, and see an error.

3.  Fix the error.

4.  Add a text field.

5.  Add code that lets your user input some text.

6.  Display the input as output.

That’s a lot of pieces, but they’re all easy.

How apps and users interact

How users get output

Users give apps input

Check your app knowledge

App-Activity: Concatenate

App-Exercise: Greeting Generator