SwiftUI views, modifiers, State, Binding, Observable, lists, navigation, layout stacks and the view lifecycle.
39 cards · basic cards · AI-written, checked twice. Edit anything.
- What does the View protocol represent in SwiftUI?
Show answer
A protocol that defines a single visual element or component that can be rendered on screen.
- How do you apply a modifier to a SwiftUI view?
Show answer
Call a modifier method on the view using dot notation, e.g., Text('Hello').padding()
- What is the @State property wrapper used for?
Show answer
To declare a local state variable in a SwiftUI view that triggers a re-render when its value changes.
- What is a VStack?
Show answer
A view that arranges child views in a vertical line from top to bottom.
- What does the Text view do?
Show answer
Displays a string of text on the screen.
- What is the @Binding property wrapper?
Show answer
A property wrapper that creates a two-way connection to a state variable from a parent view, allowing child views to read and modify it.
- Why does modifier order matter in SwiftUI?
Show answer
Modifiers are applied sequentially, and each modifier returns a new view, so the order affects the final visual result.
- What is an HStack?
Show answer
A view that arranges child views in a horizontal line from left to right.
- What does the padding modifier do?
Show answer
Adds space around a view on all sides or on specific edges.
- What is the purpose of the @StateObject property wrapper?
Show answer
To manage a reference type (Observable object) as local state in a view, creating a new instance once and persisting it across re-renders.
- What is a ZStack?
Show answer
A view that overlays child views on top of each other, arranged front to back along the z-axis.
- What does the Observable macro do?
Show answer
Marks a class as observable so that SwiftUI automatically tracks changes to its properties and re-renders dependent views.
- What is a Spacer view?
Show answer
A flexible view that expands to fill available space in its parent view.
- What does the @Published property wrapper do?
Show answer
Marks a property in an Observable class so that changes to it are automatically broadcast to dependent views.
- What is NavigationStack used for?
Show answer
To manage navigation between multiple views by maintaining a stack of views and their navigation state.