TodayTools

Swift flashcards

Apple's safe, fast language for iPhone, iPad, Mac and Watch apps.

Donate
Beginner friendly, starts from zero
Section
How to study
0
SwiftStart from zero · 1 of 11

What is Swift, in one plain sentence?

Swift is a programming language made by Apple for building apps that are fast, safe and easy to read.

Apple's language for Apple's devices, and more.
Show again
11 left
Got it

Tap to turn over. Swipe right if you know it, left to see it again.

All topics

What you will learn

  1. Start from zero

    • What Swift is and why it exists4 cards
    • Key words4 cards
    • Getting ready3 cards
  2. Core basics

    • Values and types2 cards
    • Optionals2 cards
    • Control flow2 cards
    • Functions2 cards
    • Collections3 cards
    • Structs and classes3 cards
    • Enums and errors2 cards
  3. Next steps

    • Protocols, generics and Codable5 cards
    • Closures and memory3 cards
    • Concurrency4 cards
    • SwiftUI2 cards
    • Packages and testing2 cards
  4. Go deeper

    • Value types and performance3 cards
    • Swift 6 concurrency4 cards
    • Advanced language4 cards
    • Debugging and production3 cards
    • Swift beyond the iPhone3 cards

Final test and certificate

10 questions drawn fresh from the whole topic, about 15 minutes. Sign in, score 80% or more and get a free certificate with your name and a public check link anyone can open, such as an employer or a teacher. Not signed in? Try a practice test from the cards.

Take the final test

Swift at a glance

Swift is Apple's modern programming language for building apps on iPhone, iPad, Mac, Apple Watch and Vision Pro, and it also runs on servers.

Like a well-designed toolbox with safety guards on every blade: you can build quickly, and the tools stop many slips before they cut you.

Words you will meet

Constant
A named box filled once with let that never changes
Variable
A named box made with var whose value can change
Type
The kind of value a box holds, like a whole number (Int) or text (String)
Function
A named set of steps, written with func
Optional
A box that may hold a value or be empty (nil), marked with ?
Struct
A bundle of related values that is copied when you pass it around
Closure
A small function you can pass around, written in curly braces
Xcode
Apple's free app for writing, running and testing Swift apps on a Mac

The steps

  1. 1. Start from zero (11 cards): What Swift is, where it runs and the words you need.
  2. 2. Core basics (16 cards): Types, optionals, control flow, functions, collections, structs, classes, enums and errors.
  3. 3. Next steps (16 cards): Protocols, generics, Codable, closures and ARC, async and actors, SwiftUI, packages and tests.
  4. 4. Go deeper (17 cards): Copy-on-write, Swift 6 concurrency, typed throws, macros, debugging and Swift beyond the iPhone.
All 11 cards in Start from zero
What is Swift, in one plain sentence?
Swift is a programming language made by Apple for building apps that are fast, safe and easy to read.
Why did Apple create Swift?
Apple's older language, Objective-C, was hard to learn and easy to crash. In 2014 Apple released Swift with clearer syntax and checks that stop many crashes before an app ships.
Where do you meet Swift in daily life?
Banking, food delivery, music and health apps on iPhone; widgets on your home screen; apps on your Apple Watch; and some server software.
What is an optional, using an everyday picture?
A gift box that might be empty. Swift makes you open it carefully and check before using what is inside, so the app does not crash on nothing.
What is the difference between let and var?
let makes a constant that never changes, like your birthday. var makes a variable that can change, like your step count today. Swift prefers let.
What is a struct, in plain words?
A bundle of related facts, like a contact card with name and phone. When you hand someone a struct, they get their own copy.
What is a closure?
A small piece of code in curly braces you pass to something else, like telling a button what to do when tapped: { print("Tapped") }.
What are Xcode and SwiftUI?
Xcode is Apple's free app on the Mac for writing and running Swift apps. SwiftUI is Apple's way to describe screens in Swift code, like 'a list of orders with a button'.
What do you need to start learning Swift?
A Mac with Xcode (free from the App Store) to build iPhone apps. For learning the language alone, Swift Playground on iPad or Mac, or Swift on Linux and Windows, also work.
What does a first Swift program look like?
No main function is needed in a simple script; code at the top level runs in order. let stores the name, print shows text and \(name) puts a value inside it.
After this topic, what will you be able to do?
Write clean Swift, build simple SwiftUI apps, handle data and errors safely, and answer common iOS interview questions.
Swift cheatsheet

Basics

  • let x = 5 / var y = 0 Constant / variable
  • "Hi \(name)" String interpolation
  • func f(_ a: Int, to b: Int) -> Int Function with labels
  • for i in 0..<n Loop up to n, excluding n
  • switch x { case 1...5: ...; default: ... } Exhaustive switch
  • guard cond else { return } Exit early

Optionals

  • String? May be nil
  • if let x { } Use if present
  • guard let x else { return } Require or exit
  • a?.b Optional chaining
  • a ?? fallback Default value
  • a! Force unwrap (avoid)

Types

  • struct / class Value copy / shared reference
  • enum E { case a(Int) } Cases with data
  • protocol P { func f() } Contract of abilities
  • extension Int { } Add to an existing type
  • some P / any P Fixed hidden type / mixed box
  • struct Order: Codable JSON encode and decode

Concurrency

  • func f() async throws Async function that can fail
  • try await f() Call and wait
  • async let a = f() Run in parallel
  • actor Store { } Race-free state
  • @MainActor Run on the main thread
  • Task { await load() } Start async work from sync code

SwiftUI

  • @State private var x Local view state
  • @Binding var x Parent's state, read and write
  • @Observable class Model Shared observable model
  • @Environment(\.dismiss) Read environment values
  • .task { await load() } Async work tied to the view
  • #Preview { MyView() } Live preview in Xcode
Donate