Introduction

The basic building blocks of object-oriented programming are custom types you define to model the data (objects) your app uses. You can think of custom types as templates that you can create to represent different kinds of data in your app. For instance, you might have a “Person” type with properties like name, age, and address. This “Person” type is your custom type, and it models the data related to a person. Most programming languages have two ways to define custom types: structs (structures) and classes. Swift has a preference for structs and recommends you start by using a struct until you need some feature that’s only available for classes.

In this lesson, you’ll define a MuseumObject type with properties and a method. You’ll also instantiate some objects and learn how to use them. You’ll switch between struct MuseumObject and class MuseumObject to learn about some of the differences between the types. And you’ll look at hiding one of the MuseumObject’s properties by making it private.

See forum comments
Download course materials from Github
Previous: Quiz: Basics of Object-Oriented Programming Next: Instruction