Introduction

You already understand how to use typical data types such as Int, Double, String, and Bool.

On the Interactive Apps task, you made an app that accepts input as a Double using the Slider structure:

Where whole number input is desired, it is also possible to build apps that accept input using a Stepper structure:

Steppers and sliders prevent the user from providing invalid input.

This is very helpful, however, in the case of:

  • a Slider – it can be hard to select a precise value.
  • a Stepper – it can be slow to input a large number.

Sometimes, it would be preferable to accept “free form” or typed input from the user.

What happens, though, when invalid input is received from a user?

For example, our app might expect numeric input – but the user could type fifty rather than 50.

This is when the notion of an optional data type becomes useful.

Getting started

Please download a ZIP file of this project:

Double-click to expand the ZIP file in your Downloads folder:

Move the new folder to your Computer Studies folder:

Double-click to open the folder:

Double-click the blue .xcodeproj file:

You will see the following dialog – choose Trust and Open:

You will see the opening page of the playground. Read the introduction carefully. When you ready, tap the blue link at the bottom of the page to advance:

Try each page of the playground by following instructions given, taking notes to respond to the prompts directly in your portfolio entry for Notion for today. It’s probably going to be easiest to arrange the application windows side by side. For example:

TIP

Take your time – read for understanding.

When you are finished each page of the playground summarize in writing what you have learned.

IMPORTANT

In your portfolio post, include screenshots for every page of your progress through the playground.