Module 06 of 12

Structs, Classes & Protocols

Lessons

About This Module

Every app needs a way to model its data and organize its behavior. This module introduces the building blocks Swift gives you for that: structs and classes to represent things like users, products, or settings, and protocols to describe behavior that different types can share.

You'll learn how to define properties, methods, and initializers, and the most important difference between the two: structs are value types and classes are reference types. A short video compares them side by side, so you can tell when to reach for each one. You'll then see how protocols let unrelated types promise the same capabilities.

These ideas show up constantly in SwiftUI, where views and data models are built from exactly these pieces. Some lessons are clips cut from longer courses. When you're ready, continue on to SwiftUI Fundamentals.

Lessons

5 videos
01

Structs in Swift

Define structs with properties, methods, and initializers, and see how they behave as value types.

02

Classes in Swift

Create classes, work with inheritance, and understand how they differ from structs.

03

Classes vs Structures in Swift

A short side-by-side comparison of value types and reference types, and when to use each.

04

Protocols in Swift (Clip 1)

Define protocols and have types conform to them to share behavior.

05

Protocols in Swift (Clip 2)

A second walkthrough of protocols and conformance.