Learn Swift

A structured guide to Swift, from the language fundamentals to modern concurrency, SwiftUI, testing, interoperability, and advanced Swift concepts.

Start learning Swift

Welcome

Start with what Swift is, why it exists, and how to set up a place to write your first program.

Swift Basics

Learn how Swift stores values, names types, and lets you write comments that explain the code.

Operators

See how Swift calculates, compares, and combines values, including ranges and custom precedence.

Strings & Characters

Work with text in Swift, from interpolation and multiline strings to Unicode and regular expressions.

Control Flow

Choose paths through a program with conditions, switches, pattern matching, and early exits.

Loops

Repeat work over sequences with for-in, while, stride, and forEach.

Collections

Store groups of values in arrays, sets, dictionaries, and the other collection types Swift uses.

Collection Methods & Properties

Inspect and transform collections with the methods you will use most often.

Functions

Define functions, pass arguments, return values, and understand how Swift names and overloads them.

Optionals

Represent missing values safely and unwrap them without guessing.

Custom Types

Model data with structs, enumerations, tuples, and the other value types Swift encourages.

Classes

Use reference types when identity, inheritance, or a shared instance is the right model.

Protocols & Extensions

Describe shared behavior with protocols and add methods to existing types.

Advanced Swift

Go further into generics, type casting, property wrappers, result builders, and related language features.

Higher-Order Functions

Transform collections with map, filter, reduce, and the functions built on the same idea.

Swift Error Handling

Report and recover from failures with throwing functions, try, and do-catch.

Memory & Performance

Understand how Swift keeps memory in check, and where copies and references matter.

Concurrency

Run work concurrently with async/await, tasks, and actors.

SwiftUI

Build interfaces with SwiftUI views, layout, navigation, and state.

Interoperability

Call Objective-C and C from Swift, and move data across those language boundaries.

Testing & Debugging

Check behavior with tests and find problems with the debugger and logging tools.

Expert Topics

Study the language features used in libraries, macros, and lower-level Swift.

Core Rules of Thumb

Apply the habits that keep everyday Swift clear: naming, immutability, and small functions.

Appendix

Use the glossary, style notes, and migration guides when you need a reference rather than a lesson.