Glossary
166 terms from SwiftUI, in plain words, each with the chapter that teaches it.
#
- #expect
- A Swift Testing macro that checks a condition is true. If it isn't, the test fails and shows both sides of the check, but keeps running.
- #Preview
- A macro that tells Xcode what view to draw in the canvas, so you see a screen update as you type without running the app.
- #require
- A Swift Testing macro that checks a condition and stops the test immediately if it fails. Given an optional, it unwraps it like `guard let`, and needs `try`.
- $ (dollar sign prefix)
- A `$` before a @State or @Binding property passes a binding to it, giving a control read and write access. For example, `$quantity` lets a Stepper change the quantity.
- .accessibilityElement(children: .combine)
- A modifier that joins a group of views into one element, so VoiceOver reads a whole menu row (name, kind, price) in one go.
- .accessibilityHint
- A modifier that adds a short note about what will happen, which VoiceOver reads after a pause, such as "Adds this drink to your order".
- .accessibilityLabel
- A modifier that sets what VoiceOver reads for a view whose meaning isn't in words, such as the Kettle & Crane logo.
- .badge
- A modifier that puts a red count on a tab's icon. With a count of 0 nothing shows; it attaches to the Tab, not its content.
- .contentTransition(.numericText())
- A modifier that makes the digits of a changing number roll into place, used on the order total.
- .frame
- A modifier that gives a view a size in points, such as `.frame(width: 44, height: 44)`, or lets it grow with `maxWidth: .infinity`.
- .navigationDestination
- A modifier that says which screen to build when a link carrying a value of a given type is tapped. It must sit inside the NavigationStack.
- .navigationTitle
- A modifier that gives a screen its large title. It goes on the view inside the NavigationStack, not on the stack.
- .onDelete
- A modifier on a ForEach that gives each row the standard swipe-to-delete. Its closure receives an IndexSet of deleted positions.
- .overlay
- A modifier that draws views on top of another view, used to center a spinner or error message over the menu list.
- .padding
- A modifier that adds space around a view, on every side or chosen edges such as `.horizontal` or `.top`.
- .refreshable
- A modifier that adds pull-to-refresh to a list and runs the async code you give it.
- .sheet
- A modifier that slides a screen up from the bottom, for tasks that sit apart from the navigation stack.
- .swipeActions
- A modifier whose buttons appear when you swipe a row left. A `.destructive` button shows red and a full swipe runs it, as with Remove on an order line.
- .symbolEffect
- A modifier such as `.symbolEffect(.bounce, value:)` that makes a symbol bounce each time the watched value changes.
- .symbolRenderingMode
- A modifier that controls how a symbol's layers are colored; `.hierarchical` draws them in shades of one color.
- .task
- A modifier that runs async work when a view appears and cancels it if the view goes away first. It is where the menu screen starts loading.
- .toggle()
- A method that flips a Bool: false becomes true and true becomes false.
- .toolbar
- A modifier that puts the views inside its braces into the navigation bar, such as a Clear button.
- @Bindable
- A property wrapper that lets a view make bindings, with `$`, to the properties of an @Observable object such as OrderModel. It is needed because an object read from the environment is a plain value.
- @Binding
- A property wrapper that lets a child view read and write a value owned by its parent. QuantityControl uses it so its stepper changes the drink screen's quantity.
- @Environment
- A property wrapper that reads a value SwiftUI passes down the view tree, such as the shared OrderModel or the dismiss action. You name what you want with a type (`OrderModel.self`) or a key path (`\.dismiss`).
- @main
- An attribute that marks where the app starts. Every app has exactly one, on the struct that conforms to App.
- @MainActor
- An attribute that makes a class's code run on the main thread, where the screen is drawn. OrderModel uses it so data the screens show changes in a safe place.
- @Model
- A macro that turns a Swift class, such as SavedOrder, into something SwiftData can store, with each stored property becoming a database column. It must be a class, not a struct.
- @Observable
- A macro that makes a class report changes, so any view that reads one of its properties redraws when that property changes. OrderModel uses it to share the order between screens.
- @Previewable
- A macro that lets you declare `@State` right inside a `#Preview`, so a preview can supply a value that a parent view would normally own.
- @Query
- A SwiftData property wrapper that fetches saved objects, such as past orders, and keeps the array up to date so the view redraws when data is added or deleted.
- @State
- A property wrapper for a view's own changing value, such as a quantity or typed text. SwiftUI stores the value between redraws and redraws the view when it changes.
- @Test
- An attribute placed before a function to mark it as a Swift Testing test that Xcode can run.
- @testable import
- An import that lets the test target see the app's own types, which are otherwise hidden because the app is a separate module.
A
- accessibility
- Making an app usable by everyone, including people who can't see the screen well or at all.
- Accessibility Inspector
- An Xcode developer tool that shows an element's accessibility label and hint and can step through the screen in VoiceOver's order. It stands in for VoiceOver, which the Simulator doesn't have.
- alert
- A small box over the screen with a title, a message and buttons. `.alert` shows one while its Bool binding is true and sets it back to false when a button is tapped, as with the pickup code.
- alignment
- A parameter of stacks that lines up their children, such as `.leading` in a VStack or `.top` in an HStack.
- animation
- A smooth change over a fraction of a second instead of an instant jump. `.animation(_:value:)` animates one view when a value changes (implicit); `withAnimation` animates everything a change causes (explicit).
- App
- The protocol the app's starting struct conforms to. It requires a `body` that lists the app's scenes.
- App Store Connect
- Apple's site where you upload a release build of your app, so testers can try it with TestFlight before Apple reviews it.
- App Transport Security
- The iOS rule that blocks plain `http://` connections by default and expects `https://`. The practice server needs the Allows Local Networking exemption.
- as?
- A conditional cast that gives nil if the value isn't the requested type. MenuClient uses it to check that a response is an HTTP response.
- asset catalog
- The `Assets` item in the Project navigator where images and the app icon are kept. `Image("Logo")` shows an image from it by name.
- async / await
- Swift keywords for work that pauses while waiting, such as a network reply. `await` marks the pause, during which the app keeps drawing and responding to taps.
- AsyncImage
- A SwiftUI view that downloads and shows an image from a web address, with no asset needed.
- attribute
- A word starting with `@` that adds behavior to the code after it, such as `@main` or `@State`.
B
- binding
- Read and write access to a value that someone else owns. Controls like Picker, Toggle and TextField take a binding so they can change the screen's state.
- body
- The required property of a View (or App) that describes what to show. It returns a single `some View`.
- build
- Turning your code into a runnable app. If the code has a mistake, the build stops and Xcode lists the errors.
- bundle ID
- An app's unique name, made from the organization identifier and product name, such as `com.kettleandcrane.KCOrder`. You can't change it after release.
- Button
- A view that shows a title and runs its closure (the action) when tapped. `.buttonStyle(.borderedProminent)` draws it as a filled shape.
C
- canvas
- The Xcode pane on the right where previews are drawn as you type. It has Live and Selectable modes.
- capitalized
- A Foundation property that starts each word of a string with a capital letter, so `"medium".capitalized` is `"Medium"`.
- CaseIterable
- A protocol that gives an enum an `allCases` array of all its cases, so `Size.allCases` lists small, medium and large.
- Codable
- A protocol that tells Swift to write the code converting a type to JSON and back. It works when every property is Codable and the property names match the JSON keys.
- computed property
- A property that calculates its value from other properties each time it is read, such as `OrderLine.total` or `OrderModel.summary`.
- console
- The debug area at the bottom of Xcode where `print` writes text while the app runs with Command-R. It is not shown on the app's screen.
- ContentUnavailableView
- The standard empty-screen message: a large SF Symbol with a title under it. The app shows it with a `wifi.slash` symbol when the menu fails to load.
- curl
- A Terminal command that sends a request to a web address and prints the reply. It is used to ask the practice server for menu.json.
D
- Data
- Foundation's type for raw bytes. A network reply arrives as Data, which JSONDecoder reads.
- Date
- Foundation's type for a moment in time. `.now` is the current moment, which SavedOrder stores as each order's date.
- declarative
- A style where you describe what the screen should show for the current data and SwiftUI draws it, instead of telling it how to change.
- decorative image
- An image that adds nothing to the meaning. `Image(decorative:)` or `.accessibilityHidden(true)` makes VoiceOver skip it.
- deployment target
- The oldest version of iOS that an app project supports. In Xcode it appears as Minimum Deployments in the target's General tab, and the Kettle & Crane app needs iOS 18 or later.
- dismiss
- An action read from the environment that closes the current screen when called, like tapping Back. The detail screen calls it after adding a drink to the order.
- Dynamic Type
- The iPhone's text size setting. Text styles such as `.headline` grow and shrink with it, while fixed sizes don't.
E
- environment
- A set of values SwiftUI passes down to a view and everything inside it. `.environment(model)` puts the shared OrderModel there so every screen can read it.
- extension
- Swift code that adds a new property or method to an existing type, as `money` adds a formatted-price property to every Double.
F
- final
- A keyword meaning no other class can build on this one, as in the UI test class.
- ForEach
- A view that takes an array and a closure and builds one view per element, since a view body can't hold a `for` loop. Its `id:` tells SwiftUI how to tell elements apart.
- Form
- A scrolling, grouped list made for controls, laid out as standard iOS rows like the Settings app.
- Foundation
- Apple's base framework, imported for things like URLSession, UUID, Date and string helpers; SwiftUI brings it in too. Data files without `import SwiftUI` import it directly.
- framework
- A ready-made library of Apple code you use in your own, such as SwiftUI for screens or SwiftData for saving objects.
G
- GET
- The HTTP request type that asks a server for a file or data. The app sends a GET for menu.json and the server replies with JSON.
- Grid
- A SwiftUI layout for a small table that doesn't scroll, with a GridRow per row, so columns line up.
- GridItem
- A value describing one column of a LazyVGrid: flexible by default, `.fixed` for a set width, or `.adaptive(minimum:)` to fit as many columns as space allows.
- guard
- A Swift statement that checks a condition and must leave the current scope if it fails. MenuClient uses it to throw an error for any non-200 response.
H
- Hashable
- A protocol meaning a value can be reduced to a number (its hash) so Swift can find it fast. It lets a value be a navigation link's value, a set member or a dictionary key.
- Host addresses (127.0.0.1, 0.0.0.0)
- Numeric addresses in the practice server's output: 127.0.0.1 is this computer itself (what `localhost` points to) and 0.0.0.0 means the server is listening on all of the computer's addresses.
- HStack
- A view that arranges its children in a row, left to right.
- HTTP
- The protocol web servers and apps use to talk. Plain `http://` is unencrypted and blocked by default on iOS; `https://` is the secure version real servers use.
- HTTP status codes
- A number in every web reply saying how the request went: 200 means OK (success) and 404 means the file wasn't found. MenuClient treats anything other than 200 as a bad response.
- HTTPURLResponse
- The type describing a reply from a web server, including its status code. MenuClient checks it for 200.
I
- Identifiable
- A protocol requiring an `id` property that is different for every value, so List and ForEach can tell rows apart. MenuItem has an `id`, so the conformance is free.
- if (inside a view)
- A plain `if` in a view body shows the views inside it only while the condition is true, as `if item.hasSizes` hides size options for food.
- Image
- A view that shows a picture: an SF Symbol with `Image(systemName:)`, or your own picture from the asset catalog with `Image("Name")`.
- IndexSet
- A set of row positions. The `.onDelete` closure receives one holding the rows the customer deleted.
- inMemory
- An option that makes a ModelContainer live only in memory, so nothing is written to disk. Previews use it to start with a throwaway database.
- Int.random(in:)
- Picks a whole number at random from a range. Checkout uses `1000...9999` so the pickup code always has four digits.
- Issue navigator
- The Xcode list of every error with its file and line, opened from the error count in the activity area.
J
- JSON
- The usual text format for data on the web: square brackets hold lists and curly braces hold objects of `"key": value` pairs. The menu.json file lists Kettle & Crane's drinks this way.
- JSONDecoder
- The Foundation type that turns JSON bytes (Data) into Swift values, such as `decode([MenuItem].self, from: data)`. It throws if the data isn't a valid menu.
K
- key path
- A way to name a property without reading it yet, written with a backslash. `\.self` means the element itself, and `\SavedOrder.date` means the date of a SavedOrder.
L
- LabeledContent
- A row with a title on the left and a value on the right in gray, used for order lines and history rows.
- lazy
- Building each item only when it scrolls onto the screen, which keeps a long grid fast, as in LazyVGrid.
- LazyVGrid
- A view that lays out its children in columns described by GridItem values, filling a row before starting the next, and building cells only as they appear.
- List
- A view that shows rows in a scrolling column, like the Settings app, building one row per element of an array.
- Live mode
- The canvas's default mode, where you can tap buttons and type into fields much like in a running app.
- localhost
- A name meaning "this computer". In the Simulator it reaches the practice server on your Mac, but on a real iPhone it means the phone itself.
M
- macro
- Code that writes more code for you when the file is compiled. Names starting with `#` or attributes like `@Observable` and `@Model` are macros.
- main thread
- The part of the app that draws the screen. Data screens show should change there.
- memberwise initializer
- The initializer Swift writes for a struct automatically, taking a value for each property that doesn't already have one, like `MenuCard(item:)`.
- ModelContainer
- The SwiftData database itself: it knows which model classes to store and where the file lives. You create one for the app with `.modelContainer(for:)` on the WindowGroup.
- ModelContext
- The object that tracks your changes to the database: `insert` adds an object and `delete` removes one, and the main context saves automatically.
- modifier
- A method called on a view that returns a new view with a change applied, such as `.font` or `.padding()`. Each wraps the one before, so order matters.
- module
- A separately built unit of code. The app is a module of its own, so the test target needs `@testable import` to see its types.
- money
- A custom computed property added to `Double` through an extension that formats a number as a dollar price with two decimals, so `4.75.money` gives `"$4.75"`.
- multi-line string literal
- Text between `"""` lines, so a string such as JSON can keep its quotes and line breaks.
N
- NavigationLink
- A view that makes a row tappable; it shows its label with a chevron and carries a value that a `.navigationDestination` turns into a screen.
- NavigationStack
- A view that holds a stack of screens: tapping a link pushes a screen on top and the Back button pops it off.
- NSPredicate
- A search condition, such as `label CONTAINS 'Latte'`, which the UI test uses to find the Latte row.
O
- opaque type
- A type written `some Something`, meaning "some type that conforms to it; Swift works out which". A view's body is `some View` so you don't write the long real type.
P
- Picker
- A control for choosing one value from a set through a binding. Each choice has a `.tag` matching the binding's type, and `.pickerStyle(.segmented)` shows choices side by side.
- points
- The screen's unit of length, used for spacing and frame sizes.
- ProgressView
- The spinning activity indicator, shown over the empty menu while it loads.
- project
- The folder of files and settings Xcode builds into an app.
- Project navigator
- The Xcode sidebar on the left that lists your project's files.
- property wrapper
- An attribute on a property that changes how it is stored. With `@State`, SwiftUI holds the real value and the property reads and writes it.
- python3 -m http.server
- A Terminal command that starts Python's built-in web server, which serves the files in the current folder over HTTP. For example, `python3 -m http.server 8080` serves a `menu.json` file at `http://localhost:8080/menu.json`, which is handy for practicing network requests.
R
- Reduce Motion
- An iPhone setting for people who get dizzy from movement. A view reads it with `@Environment(\.accessibilityReduceMotion)` and can turn animations off.
- run destination
- The device menu in Xcode's toolbar where you choose which simulated or real iPhone to run on. Command-R then builds and runs the app there.
S
- SavedOrder
- A SwiftData `@Model` class for a past order, storing its pickup code, summary, total and date. It lets the History tab list orders that persist after the app is closed.
- scene
- A part of the app the system shows. `WindowGroup` is the usual scene: the window that fills the iPhone's screen and holds the first screen.
- Section
- A group of rows, with an optional header, inside a Form or List.
- Selectable mode
- A canvas mode where double-clicking something highlights its code in the editor, useful for seeing how much space a view takes.
- SF Symbols
- Apple's free set of thousands of icons that match the system font, named by text such as `cup.and.saucer.fill`. You size and color them like text.
- Shapes (Circle, RoundedRectangle)
- Views that draw a shape as large as the space they are offered, painted with `.fill`. Give them a `.frame` and usually layer them in a ZStack behind text or a symbol.
- Simulator
- The part of Xcode that runs a simulated iPhone in a window on your Mac, so you can test without a real phone. It has no VoiceOver.
- Spacer
- A view that takes all the free space along its stack, such as pushing the price to the right edge of a menu row.
- spacing
- A stack parameter that sets the gap between children in points.
- state
- Data that changes while the app runs, such as a count, a choice or typed text. Views are remade often, so changing data lives in state.
- static
- A keyword that makes a property belong to the type itself rather than to each value, such as the one shared `MenuItem.samples` array.
- Stepper
- A control showing a label with minus and plus buttons, bound to a number and limited to a range such as `1...10`.
- suite
- A struct that groups tests in Swift Testing. Its properties are set up fresh for each test.
- Swift Testing
- Apple's framework for tests written in Swift, using `@Test`, `#expect` and `#require`.
- SwiftData
- Apple's framework for saving objects on the device. You describe the data as a Swift class and it stores it in a small database file and keeps views up to date.
- SwiftUI
- Apple's framework for building app screens in Swift, with text, buttons, lists and forms. It runs on iPhone, iPad, Mac, Apple Watch and Apple TV.
T
- Tab
- One button of a TabView, with a title, an SF Symbol and the view it shows.
- TabView
- A view that puts a tab bar along the bottom of the screen, with one button per Tab.
- target
- One product built from a project, such as the app or its tests. A test target is built only for testing and never shipped.
- ternary operator
- `condition ? a : b` gives `a` when the condition is true and `b` otherwise.
- TestFlight
- Apple's service for letting testers try your app before Apple reviews it; it is reached through App Store Connect.
- Text
- A view that shows a line of text. You style it with modifiers such as `.font`, `.bold()` and `.foregroundStyle`.
- text styles
- Named font sizes such as `.largeTitle`, `.headline` and `.body` that grow and shrink with the person's text size setting.
- TextField
- A box for typing, bound to a String, with a gray placeholder shown while it is empty.
- throws
- Swift's error handling: a function marked `throws` can fail, callers use `try`, and `catch` handles the error. `loadMenu` catches every error and turns it into a message.
- Ticket
- A struct of `let` properties holding what a customer receives at checkout: pickup code, name, pickup time, order summary and total. It is plain data that is built once and never changed.
- Toggle
- An on/off switch bound to a Bool, such as the oat milk option.
- top-level constant
- A constant declared outside any type, so every file in the app can use it, like `pickupTimes`.
- trailing closure
- A closure written after a call's parentheses, such as a Button's action or the row builder of a List. When a call ends with several closures, later ones follow with their labels, as in `.alert`.
- transition
- How a view appears and disappears, such as `.transition(.scale)`. It only plays when the state change happens inside `withAnimation`.
U
- UI test
- A test that launches the whole app and taps through it like a customer, using XCTest, to check the screens work together.
- unit test
- A small function that runs one piece of code, such as OrderLine's total, and checks the result. It runs in seconds.
- URL
- Foundation's type for a web address. `URL(string:)` returns an optional because not every string is a valid address.
- URLSession
- The part of Foundation that talks to web servers. `URLSession.shared.data(from:)` sends a request and waits, without freezing the app, for the reply.
- UUID
- A universally unique ID, a long random value never repeated. OrderLine uses one so two lines for the same drink can still be told apart.
V
- View
- The protocol at the heart of SwiftUI: any struct with a `body` of type `some View` can be shown on screen. A view is a small, cheap description of part of the screen.
- VoiceOver
- The iPhone's screen reader: it reads aloud the item under your finger and a double tap presses it.
- VStack
- A view that arranges its children in a column, top to bottom.
W
- withAnimation
- A function that wraps code changing state so every view change it causes is animated. Transitions need it to play.
X
- Xcode
- Apple's free app for writing, building and testing apps; it includes the Simulator and previews.
- XCTest
- Apple's older test framework, used here for UI tests. Tests are methods of a class based on XCTestCase, and their names start with `test`.
- XCUIApplication
- The XCTest type standing for your app in a UI test; `launch()` starts it in the Simulator so the test can tap through it.
Z
- ZStack
- A view that layers its children back to front, with the first child at the back.