O'Reilly logo

Learning Swift by Andrew J Wagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Bringing it all together

At this point, you have learned a lot about the basic workings of Swift. Let's take a moment to bring many of these concepts together in a single program. We will also see some new variations on what we learned.

The goal of the program will be to take a list of invitees and television shows and to ask random people to bring a show of each genre and to ask the rest to just bring themselves.

Before we look at the code, there are three small new features that we will use:

  • We will generate a random number
  • We will use a variable to store only true or false
  • We will use a new type of loop called a do-while loop

The most important feature is the ability to generate a random number. To do this, we have to import Foundation Framework ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required