15 Structs and Classes

Structures (commonly referred to as structs) and classes are the pillars on which you build your applications. They provide important mechanisms to model the things you wish to represent in your code.

You are going to transition from the playground and create a command-line tool, which you will work in for the next several chapters. Your command-line tool project will represent a town undergoing a serious monster infestation. You will use both structs and classes to model these entities and will give them properties to store data and functions so that these entities can do some work.

As you will see, structs and classes have similarities and differences. Which to use for any particular situation is an important ...

Get Swift Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.