Welcome to your comprehensive Xcode and Swift reference!
This guide covers essential terms, SwiftUI modifiers, layout concepts, and acronyms you'll encounter as you develop iOS apps.
Click a Term to See Explanation
Term | Definition / Explanation | Examples |
---|---|---|
Array | An ordered collection of values of the same type. Arrays allow duplicates and maintain insertion order. Access elements by index (starting at 0). Arrays are mutable if declared with var and immutable with let . One of the most commonly used collection types. |
var numbers = [1, 2, 3, 4, 5]
numbers.append(6) let first = numbers[0] let names = ["Alice", "Bob", "Charlie"]
for name in names { print(name) } |
@Binding | A property wrapper that creates a two-way connection between a property and a source of truth stored elsewhere. Use @Binding when a child view needs to read and write a value owned by a parent view. Changes made via the binding automatically update the original source. Essential for passing editable data down the view hierarchy. |
struct ChildView: View {
@Binding var text: String var body: some View { TextField("Enter", text: $text) } } |
class | A reference type that defines an object with properties and methods. Unlike structs, classes are reference types (they're shared, not copied). Classes support inheritance (one class can inherit from another). Use classes when you need shared state or inheritance. In SwiftUI, you'll often use classes for ObservableObject types. |
class ViewModel: ObservableObject {
@Published var count = 0 func increment() { count += 1 } } |
Closure | A self-contained block of code that can be passed around and used in your code. Similar to functions but can be anonymous and capture values from their surrounding context. Often used as completion handlers, callbacks, and for functional programming. Can be stored in variables and passed as parameters. |
let greeting = { (name: String) in
print("Hello, \(name)") } greeting("Bob") Button("Tap") {
print("Tapped!") } // Closure as button action |
Computed Property | A property that doesn't store a value but calculates it each time it's accessed. Uses get to retrieve the value and optionally set to modify other properties. Useful for derived values that depend on other properties. Helps keep your code DRY (Don't Repeat Yourself). |
struct Rectangle {
var width: Double var height: Double var area: Double { width * height } } |
Dictionary | A collection of key-value pairs where each key is unique. Provides fast lookup of values by their keys. Keys must be hashable (strings, integers, etc.). Access returns an optional because the key might not exist. Unordered collection. |
var ages = ["Alice": 25, "Bob": 30]
ages["Charlie"] = 28 if let age = ages["Alice"] { print(age) } |
Enum | Short for "enumeration" - defines a type with a fixed set of possible values (cases). Enums are great for representing a finite set of related values. They can have associated values and methods. Type-safe alternative to using strings or integers. Switch statements work perfectly with enums. |
enum Direction {
case north, south case east, west } enum LoadingState {
case idle case loading case success(Data) case failure(Error) } |
@Environment | A property wrapper that reads values from the environment passed down from parent views. The environment includes system settings like color scheme, size classes, and custom values you inject. Allows child views to access shared data without explicit passing. Great for app-wide settings. |
@Environment(\.colorScheme) var colorScheme
// Access dark/light mode @Environment(\.dismiss) var dismiss
Button("Close") { dismiss() } |
@EnvironmentObject | A property wrapper that reads a shared object from the environment. The object must be placed in the environment by an ancestor view using .environmentObject() . Useful for dependency injection and sharing data across many views without passing it explicitly. If the object isn't in the environment, your app will crash. |
@EnvironmentObject var settings: AppSettings
// Parent view: .environmentObject(AppSettings()) |
Extension | A way to add new functionality to existing types (classes, structs, enums, protocols) without modifying their original source code. You can add methods, computed properties, initializers, and more. Extensions help organize code and add features to types you don't own (like Apple's types). Very powerful for code organization. |
extension String {
var isEmail: Bool { contains("@") } } "test@email.com".isEmail |
func | Short for "function" - a reusable block of code that performs a specific task. Functions can take inputs (parameters) and return outputs (return values). They help organize your code into logical, reusable pieces. Functions can be called multiple times throughout your program. |
func greet(name: String) {
print("Hello, \(name)!") } greet(name: "Alice") func add(a: Int, b: Int) -> Int {
return a + b } |
Guard | A control flow statement that exits the current scope if a condition isn't met. Often used to unwrap optionals safely. Guard improves code readability by handling the "bad" cases early and exiting. The else block must exit the scope (return, break, continue, or throw). Reduces nested if statements. |
guard let user = currentUser else {
print("No user") return } // Continue with user |
If Let | A safe way to unwrap an optional value. If the optional contains a value, it's unwrapped and bound to a constant within the if block. If the optional is nil, the else block executes (if present). This prevents crashes from forced unwrapping. One of the most common patterns in Swift. |
if let email = user.email {
sendMessage(to: email) } else { print("No email found") } |
Import | A statement that makes frameworks, libraries, or modules available in your code. Imports give you access to external code and functionality. SwiftUI apps commonly import SwiftUI, Foundation, and other frameworks. Must appear at the top of your Swift files. |
import SwiftUI
import Foundation import CoreLocation |
Initializer (init) | A special method that creates and prepares a new instance of a struct or class. Sets up initial values for properties. Can have parameters to customize initialization. Every property must have a value by the end of initialization. Structs get automatic memberwise initializers. |
struct User {
var name: String var age: Int init(name: String, age: Int) { self.name = name self.age = age } } |
let | A keyword used to declare a constant whose value cannot change after it's initially set. Constants are immutable, providing safety and clarity in your code. Use let when the value should remain the same throughout the program. Swift encourages using constants whenever possible. |
let appName = "WM8b"
// appName = "Other" ❌ Error! let pi = 3.14159
let maxUsers = 100 |
@ObservedObject | A property wrapper for subscribing to an observable object that's owned elsewhere. Use @ObservedObject when an object is passed into a view from a parent. The view watches for changes but doesn't own the object. When the object publishes changes, the view updates. Similar to @StateObject but doesn't create the object. |
struct DetailView: View {
@ObservedObject var viewModel: UserViewModel // Object passed from parent } |
Optional | A type that can hold either a value or nothing (nil). Optionals are crucial for safety - they force you to handle the absence of a value. Declared with a question mark after the type. You must unwrap optionals before using their values. Prevents crashes from unexpected nil values. |
var name: String? = nil
name = "Alice" if let unwrapped = name {
print(unwrapped) } |
Protocol | A blueprint of methods, properties, and requirements that a type must implement. Think of it as a contract - any type that conforms to a protocol must provide the required functionality. Protocols enable polymorphism and abstraction. SwiftUI's View is a protocol. Great for dependency injection and testing. |
protocol Drivable {
var speed: Int { get } func drive() } struct Car: Drivable { var speed = 60 func drive() { } } |
@Published | A property wrapper used inside ObservableObject classes to announce when a property changes. Any view observing this object will automatically update when a @Published property changes. Essential for the ObservableObject pattern. Causes the objectWillChange publisher to fire. |
class DataModel: ObservableObject {
@Published var items: [String] = [] @Published var isLoading = false } |
Self vs self | self (lowercase) refers to the current instance of a type. Used to access properties and methods of the current object. Self (uppercase) refers to the type itself, useful in protocols and type methods. Understanding the difference is important for clarity in your code. |
struct Counter {
var value = 0 func increment() { // self.value += 1 } } |
@State | A property wrapper that tells SwiftUI to monitor a variable for changes and update the view automatically when it changes. Use @State for simple values that are owned by a single view. When the state changes, SwiftUI re-renders the view. This is fundamental for creating interactive interfaces. State should be private to the view. |
@State private var isOn = false
Toggle("Switch", isOn: $isOn) @State private var count = 0
Button("Tap") { count += 1 } Text("\(count)") |
@StateObject | A property wrapper used to create and own an observable object within a view. Use @StateObject when a view creates an instance of an ObservableObject. The object persists as long as the view exists. SwiftUI manages the object's lifecycle. Use this for view models that should survive view updates. |
@StateObject var viewModel = GameViewModel()
// ViewModel persists across view updates |
struct | A structure is a custom data type that groups related properties and functions together. Structs are value types (they're copied when passed around). In SwiftUI, views are structs. They're lightweight and safe because each copy is independent. Great for modeling data and creating SwiftUI views. |
struct User {
var name: String var age: Int } struct ContentView: View {
var body: some View { Text("Hello") } } |
Tuple | A lightweight way to group multiple values into a single compound value. Values can be of different types. Access elements by index or by name (if labeled). Useful for returning multiple values from a function. More flexible than arrays but less structured than structs. |
let person = (name: "Alice", age: 25)
print(person.name) func getUser() -> (String, Int) {
return ("Bob", 30) } |
Type Inference | Swift's ability to automatically determine the type of a value based on the value you assign. You don't always need to explicitly specify types - Swift figures it out. Makes code cleaner while maintaining type safety. The compiler analyzes the code context to infer types. |
let age = 25 // Swift infers Int
let name = "Alice" // Swift infers String let items = [1, 2, 3] // [Int] |
var | A keyword used to declare a variable whose value can change after it's set. Variables are mutable, meaning you can modify their values throughout your code. Use var when you know the value will need to be updated later. |
var userName = "John"
userName = "Jane" // Can change var score = 0
score += 10 // Now 10 |
Modifier | Definition / Explanation | Examples |
---|---|---|
.accentColor() | Sets the tint color for interactive elements. Applies to buttons, links, and other tappable items. Deprecated in iOS 15+ in favor of .tint(), but still common. Defines your app's primary interactive color. Can be set app-wide or per-view. |
Button("Tap") { }.accentColor(.purple)
NavigationView { }.accentColor(.green)
|
.alert() | Presents an alert dialog to the user. Shows a title, message, and buttons. Used for important information, confirmations, or errors. Modal - blocks interaction with the rest of the app. Automatically dismisses when a button is tapped. Essential for user communication. |
.alert("Error", isPresented: $showAlert) {
Button("OK") { } } message: { Text("Something went wrong") } |
.animation() | Applies an animation to a view when its state changes. Specifies the animation curve and duration. SwiftUI automatically animates changes to animatable properties. Can apply to specific values or all changes. Crucial for creating smooth, polished user experiences. |
Circle().scaleEffect(scale).animation(.easeInOut, value: scale)
Text("Fade").opacity(show ? 1 : 0).animation(.default, value: show)
|
.background() | Adds a background behind a view. Can be a color, gradient, image, or even another view. The background doesn't affect the view's size. Layers the background behind the view's content. Very versatile for creating visual depth and emphasis. |
Text("Hello").background(Color.blue)
VStack { }.background(LinearGradient(...))
Text("Card").background(RoundedRectangle(...).fill(.white))
|
.bold() | Makes text bold (heavier font weight). Can be called on text views or as part of font modifiers. Simple way to add emphasis. Works with any font. Common for headings, buttons, and important information. |
Text("Important").bold()
Text("Title").font(.title).bold()
|
.clipShape() | Clips a view to a specific shape. More flexible than cornerRadius. Can use any shape: Circle, Capsule, RoundedRectangle, or custom shapes. The view content outside the shape is cut off. Useful for creating circular avatars, custom card shapes, etc. |
Image("avatar").clipShape(Circle())
VStack { }.clipShape(RoundedRectangle(cornerRadius: 15))
Text("Pill").clipShape(Capsule())
|
.cornerRadius() | Rounds the corners of a view by a specified radius. Creates smooth, rounded corners instead of sharp 90-degree angles. Applied to the view's clipping shape. Higher values create more rounded corners. Essential for modern, friendly UI design. Zero radius means sharp corners. |
Rectangle().fill(.blue).cornerRadius(10)
Image("photo").cornerRadius(15)
VStack { }.background(.white).cornerRadius(20)
|
.disabled() | Enables or disables user interaction with a view. Takes a Boolean parameter. When disabled, views appear dimmed and don't respond to touches. Useful for form validation and conditional interaction. Affects the view and all its children. |
Button("Submit") { }.disabled(username.isEmpty)
TextField("Name", text: $name).disabled(isLocked)
|
.font() | Sets the font style, size, and weight for text. Can use system fonts (body, title, headline, etc.) or custom fonts. System fonts automatically adapt to user's accessibility settings. Supports dynamic type for better accessibility. Font choice significantly impacts readability. |
Text("Title").font(.title)
Text("Large").font(.system(size: 24))
Text("Bold").font(.headline.bold())
|
.foregroundColor() | Sets the color of text and other foreground elements. Accepts Color values including system colors and custom colors. Deprecated in iOS 15+ in favor of .foregroundStyle() , but still widely used. Applies to text, SF Symbols, and other foreground content. |
Text("Red").foregroundColor(.red)
Text("Custom").foregroundColor(Color.blue)
Image(systemName: "star").foregroundColor(.yellow)
|
.foregroundStyle() | Modern replacement for foregroundColor. More powerful - supports gradients, hierarchical colors, and materials. Introduced in iOS 15. Can accept multiple style parameters for hierarchical styling. Recommended for new code over foregroundColor. |
Text("Gradient").foregroundStyle(.linearGradient(...))
Text("Blue").foregroundStyle(.blue)
|
.frame() | Sets the size and alignment of a view. Can specify width, height, or both. Can set minimum, ideal, and maximum sizes. Allows alignment within the frame. Essential for controlling view dimensions. Without frame, views size to their content. |
Text("Box").frame(width: 200, height: 100)
Color.blue.frame(maxWidth: .infinity)
Text("Hi").frame(minWidth: 100, maxHeight: 50)
|
.italic() | Makes text italic (slanted). Used for emphasis, quotes, or stylistic purposes. Can combine with other text modifiers. Works with system and custom fonts. Creates a distinct visual style for differentiation. |
Text("Quote").italic()
Text("Emphasis").font(.body).italic()
|
.listStyle() | Changes the appearance of a List view. Options include .plain, .grouped, .insetGrouped, .sidebar, and more. Each style has a different visual presentation and spacing. Choose based on content type and platform. Affects the entire list's appearance. |
List { }.listStyle(.grouped)
List { }.listStyle(.insetGrouped)
|
.navigationBarTitleDisplayMode() | Controls how the navigation title is displayed. Options include .large (big title), .inline (small title), and .automatic. Large titles are more prominent and scroll to inline. Inline titles are always small. Affects the visual hierarchy and feel of your navigation. |
.navigationTitle("Details").navigationBarTitleDisplayMode(.inline)
|
.navigationTitle() | Sets the title displayed in a navigation bar. Only works inside a NavigationView or NavigationStack. The title appears at the top of the screen. Automatically resizes and adjusts based on scroll position (large title behavior). Essential for navigation hierarchy clarity. |
NavigationView {
List { } .navigationTitle("My Items") } |
.offset() | Moves a view from its natural position by specified x and y values. Positive x moves right, negative moves left. Positive y moves down, negative moves up. Doesn't affect layout of other views - it's a visual offset only. Useful for animations and fine-tuning positions. |
Text("Moved").offset(x: 20, y: 10)
Image("icon").offset(y: -5)
|
.onAppear() | Executes code when a view appears on screen. Called after the view is added to the view hierarchy. Useful for loading data, starting animations, or tracking analytics. Commonly used for initialization tasks. Only called once when the view first appears (unless it's removed and re-added). |
Text("Hi").onAppear {
print("View appeared") loadData() } |
.onDisappear() | Executes code when a view is about to disappear from screen. Called before the view is removed from the view hierarchy. Useful for cleanup, canceling operations, or saving state. Opposite of onAppear. Good for resource management. |
Text("Bye").onDisappear {
print("View disappeared") saveData() } |
.opacity() | Sets the transparency of a view. Value ranges from 0.0 (completely transparent/invisible) to 1.0 (completely opaque/visible). Useful for fade effects, disabled states, and layering. Applies to the entire view including its children. Commonly animated for transitions. |
Text("Faded").opacity(0.5)
Image("bg").opacity(0.3)
Button("Disabled") { }.opacity(isEnabled ? 1.0 : 0.5)
|
.overlay() | Layers a view on top of another view. The overlay is centered by default but can be aligned. Doesn't affect the size of the original view. Useful for badges, labels, or decorative elements on top of content. Opposite of background. |
Image("photo").overlay(Text("NEW"), alignment: .topTrailing)
Circle().overlay(Image(systemName: "star"))
|
.padding() | Adds space around a view's content. Can specify amount and edges. Without parameters, adds default padding on all sides. With parameters, you can control specific edges and amounts. Essential for proper spacing and visual breathing room in your UI. |
Text("Hello").padding()
Text("Hi").padding(.horizontal, 20)
VStack { }.padding([.top, .bottom], 10)
|
.rotationEffect() | Rotates a view by a specified angle. Angle is in degrees or radians. Positive values rotate clockwise. Rotation happens around the view's center (by default). Doesn't affect layout of surrounding views. Great for animations and visual effects. |
Image("arrow").rotationEffect(.degrees(45))
Text("Spin").rotationEffect(.degrees(rotation))
|
.scaleEffect() | Scales a view larger or smaller. Value of 1.0 is normal size, less than 1 shrinks, greater than 1 enlarges. Can specify different x and y scales. Scales from the center by default. Doesn't affect layout - it's a visual scaling only. Useful for emphasis and animations. |
Text("Big").scaleEffect(1.5)
Image("icon").scaleEffect(x: 2, y: 1)
Button("Press") { }.scaleEffect(isPressed ? 0.95 : 1.0)
|
.shadow() | Adds a shadow effect around a view. Specify color, radius (blur), and offset (x, y position). Creates depth and elevation in your UI. Larger radius means more blur. Offset determines shadow direction. Can be subtle or dramatic based on parameters. |
Text("Card").shadow(radius: 5)
RoundedRectangle().shadow(color: .gray, radius: 10, x: 0, y: 5)
Image("icon").shadow(color: .black.opacity(0.3), radius: 8)
|
.sheet() | Presents a modal sheet that slides up from the bottom. Used for secondary content, forms, or details. Can be dismissed by swiping down. Takes a binding to control presentation. The content is a separate view. Great for user input or additional information without leaving the current context. |
.sheet(isPresented: $showSheet) {
DetailView() } Button("Show") { showSheet = true }
.sheet(isPresented: $showSheet) { SettingsView() } |
.tabItem() | Defines the icon and label for a tab in a TabView. Shows at the bottom of the screen in tab bar. Requires an image (usually SF Symbol) and text. Users tap to switch between tabs. Essential for multi-section apps with tab-based navigation. |
Text("Home").tabItem {
Image(systemName: "house") Text("Home") } |
.tint() | Modern replacement for accentColor. Sets the tint color for controls and interactive elements. More flexible than accentColor. Introduced in iOS 15. Can accept colors, gradients, and more. Preferred for new code. |
Button("Save") { }.tint(.blue)
TextField("Name", text: $name).tint(.purple)
|
.toolbar() | Adds items to the navigation bar or bottom toolbar. Can place buttons, text, or other views. Specify placement (leading, trailing, principal, etc.). Modern replacement for navigationBarItems. Flexible and powerful for customizing navigation areas. |
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) { Button("Add") { } } } |
.transition() | Defines how a view appears and disappears. Used with if statements or conditional rendering. Built-in transitions include slide, scale, opacity, and move. Can create custom transitions. Automatically animated when views are added/removed. Makes UI changes feel natural and polished. |
if showView {
Text("Hello").transition(.slide) } Text("Scale").transition(.scale)
|
Term / Function | Definition / Explanation | Examples |
---|---|---|
alignment | A parameter in stacks that controls how views are positioned perpendicular to the stack's axis. In VStack: leading, center, trailing. In HStack: top, center, bottom. In ZStack: controls positioning of layered views. Proper alignment is crucial for polished UI. Default is usually center. |
VStack(alignment: .leading) {
Text("Left aligned") Text("Also left") } HStack(alignment: .top) {
Image("icon") Text("Text aligns to top") } |
.aspectRatio() | A modifier that constrains a view's dimensions to a specific ratio. Maintains the aspect ratio when resizing. Can use .fit (scales to fit inside available space) or .fill (scales to fill available space). Important for images and videos. Prevents distortion. Calculated as width / height. |
Image("photo").aspectRatio(contentMode: .fit)
Rectangle().aspectRatio(16/9, contentMode: .fit)
|
Divider | A thin line that separates content. Horizontal in VStack, vertical in HStack. Automatically adapts to the context. Useful for visual separation between sections or items. Respects the system's preferred divider style. Simple but effective for organization. |
VStack {
Text("Section 1") Divider() Text("Section 2") } HStack {
Text("Left") Divider() Text("Right") } |
ForEach | A structure that creates views from a collection of data. Iterates over an array or range and generates views. Each item must be identifiable (using id or Identifiable protocol). Essential for dynamic content. Often used inside Lists, VStacks, and HStacks. More efficient than manually creating multiple views. |
ForEach(0..<5) { index in
Text("Row \(index)") } ForEach(users) { user in
UserRow(user: user) } |
GeometryReader | A container that provides its size and coordinate space to its child view. Allows you to create layouts based on available space. The child receives a GeometryProxy with size information. Useful for responsive designs and custom layouts. Often used for creating views that adapt to screen size. Can be tricky - use sparingly. |
GeometryReader { geometry in
Text("Width: \(geometry.size.width)") } GeometryReader { geo in
Circle() .frame(width: geo.size.width * 0.8) } |
Grid | A container that arranges views in a two-dimensional grid layout (introduced in iOS 16). More flexible than rows and columns alone. Automatically sizes based on content. Supports spanning multiple rows or columns. Modern alternative to using nested stacks for grid layouts. Simplifies complex grid UI. |
Grid {
GridRow { Text("A") Text("B") } GridRow { Text("C") Text("D") } } |
Group | A container that groups multiple views together without affecting layout. Useful for applying modifiers to multiple views at once. Doesn't add any visual styling or layout behavior. Helps organize code and avoid view count limits. Often used with conditional content and modifiers. Invisible in the layout hierarchy. |
Group {
Text("Line 1") Text("Line 2") } .font(.title) Group {
if condition { ViewA() } else { ViewB() } } |
HStack | A horizontal stack that arranges child views in a horizontal line, side by side. The first view is on the left (in left-to-right languages). Can specify spacing and alignment (top, center, bottom). Essential for horizontal layouts like buttons in a row or labels next to icons. |
HStack {
Image(systemName: "star") Text("Favorite") } HStack(spacing: 10) {
Button("Cancel") { } Button("OK") { } } |
LazyHGrid | A lazy-loading horizontal grid with flexible row layout. Define rows with GridItem, and content flows horizontally. Horizontal equivalent of LazyVGrid. Useful for horizontally scrolling sections with multiple rows. Common in media apps for categories of content. |
let rows = [GridItem(.fixed(100)), GridItem(.fixed(100))]
LazyHGrid(rows: rows) { ForEach(items) { item in Image(item.name) } } |
LazyHStack | A horizontal stack that creates views lazily (only when needed). More memory efficient than HStack for many items. Use inside horizontal ScrollView. Horizontal equivalent of LazyVStack. Great for image galleries or horizontal carousels with many items. |
ScrollView(.horizontal) {
LazyHStack { ForEach(photos) { photo in PhotoView(photo) } } } |
LazyVGrid | A lazy-loading vertical grid with flexible column layout. Define columns with GridItem, and the grid handles the layout. Creates items on-demand for performance. Great for photo galleries, app icons, or product grids. Automatically wraps to new rows. More flexible than manual row/column stacks. |
let columns = [GridItem(.flexible()), GridItem(.flexible())]
LazyVGrid(columns: columns) { ForEach(items) { item in ItemView(item) } } |
LazyVStack | A vertical stack that creates views lazily (only when they're about to appear on screen). More memory efficient than VStack for large amounts of content. Use inside ScrollView for better performance. Views are created on-demand as you scroll. Helps prevent memory issues with lots of items. |
ScrollView {
LazyVStack { ForEach(1...1000) { num in Text("Item \(num)") } } } |
List | A container that displays rows of data in a scrollable list. Optimized for performance with many items (uses cell recycling). Supports sections, swipe actions, and editing. Similar to UITableView in UIKit. Great for displaying collections of data. Automatically handles scrolling and styling. Native look and feel. |
List {
Text("Item 1") Text("Item 2") } List(items) { item in
Text(item.name) } |
NavigationLink | A button that triggers navigation to another view. Used inside NavigationView or NavigationStack. The destination view is pushed onto the navigation stack. Automatically shows as a row in Lists with a chevron. Tapping navigates forward; back button appears automatically. Essential for multi-screen apps. |
NavigationLink("Details", destination: DetailView())
NavigationLink(destination: ProfileView()) {
HStack { Image("avatar") Text("Profile") } } |
NavigationStack | Modern replacement for NavigationView (iOS 16+). More powerful and flexible for managing navigation state. Supports programmatic navigation and deep linking better. Provides more control over the navigation stack. Recommended for new projects. Works with NavigationLink and navigationDestination. |
NavigationStack {
List(items) { item in NavigationLink(value: item) { Text(item.name) } } .navigationDestination(for: Item.self) { item in DetailView(item) } } |
NavigationView | A container that manages a navigation hierarchy and presents a navigation bar. Push and pop views in a stack. Provides back button automatically. Shows navigation title and toolbar. Deprecated in iOS 16 in favor of NavigationStack. Foundation of navigation-based apps. Creates the familiar drill-down experience. |
NavigationView {
List(items) { item in NavigationLink(item.name, destination: DetailView(item)) } } |
.resizable() | A modifier that makes an image able to be resized. Without this, images display at their original size. Must be applied before frame or aspectRatio modifiers. Essential for responsive image layouts. Allows the image to scale up or down. Usually combined with aspectRatio to prevent distortion. |
Image("photo")
.resizable() .aspectRatio(contentMode: .fit) .frame(width: 200) |
SafeArea | The portion of the screen not obscured by system UI elements (notch, home indicator, status bar, navigation bar). Views should respect safe area to avoid content being cut off. SwiftUI views automatically respect safe area by default. Can be ignored with .ignoresSafeArea(). Critical for modern iPhone designs. |
// Respects safe area by default
Text("Safe") // Ignores safe area
Color.blue.ignoresSafeArea() |
ScrollView | A scrollable container for content that exceeds the screen size. Can scroll vertically (default), horizontally, or both. Contains a single child view (often a VStack or HStack). Automatically shows/hides scroll indicators. Essential when content is taller or wider than the screen. Provides smooth, native scrolling behavior. |
ScrollView {
VStack { ForEach(items) { item in Text(item) } } } ScrollView(.horizontal) {
HStack { ... } } |
Spacer | A flexible space that expands to push views apart. Takes up all available space between views. Essential for creating flexible layouts. In an HStack, pushes views to the edges horizontally. In a VStack, pushes views apart vertically. Can set minimum length. |
HStack {
Text("Left") Spacer() Text("Right") } VStack {
Text("Top") Spacer() Text("Bottom") } |
spacing | A parameter that sets the distance between child views in a stack. Measured in points. Default spacing varies by context. Can be set to 0 for no space, or any positive number. Consistent spacing improves visual rhythm. Negative values work but are rare. |
VStack(spacing: 20) {
Text("Spaced") Text("Apart") } HStack(spacing: 0) {
Image("icon1") Image("icon2") } |
TabView | A container that displays multiple child views with a tab bar at the bottom. Users switch between tabs by tapping. Each tab has its own view and tab item (icon and label). Common pattern in iOS apps for top-level navigation. Supports badge counts. Up to 5 tabs typically; more overflow into "More" tab. |
TabView {
HomeView() .tabItem { Label("Home", systemImage: "house") } SettingsView() .tabItem { Label("Settings", systemImage: "gear") } } |
VStack | A vertical stack that arranges child views in a vertical line, one below another. The first view is at the top. Can specify spacing between items and alignment (leading, center, trailing). Fundamental for vertical layouts. Each child view stacks below the previous one. |
VStack {
Text("Top") Text("Middle") Text("Bottom") } VStack(spacing: 20) {
Image("logo") Text("Title") } |
ZStack | A depth-based stack that overlays views on top of each other. The first view is at the back, each subsequent view layers on top. Can specify alignment for positioning. Perfect for layering images with text, or creating overlays. Think of it as layers in a stack, like papers on a desk. |
ZStack {
Image("background") Text("Overlay") } ZStack(alignment: .topTrailing) {
Rectangle().fill(.blue) Text("Badge") } |
Acronym | Definition / Explanation | Examples / Context |
---|---|---|
API | Application Programming Interface - A set of rules and protocols that allow different software components to communicate. In iOS development, you use Apple's APIs to access system features. Also refers to web APIs for fetching data from servers. Defines how to request and receive data or functionality. |
"Call the weather API to get forecast data"
"URLSession is Apple's API for networking" "REST API endpoints" |
CPU | Central Processing Unit - The main processor that executes instructions in a device. In iOS devices, Apple's A-series and M-series chips. Heavy computation can cause high CPU usage and battery drain. Efficient code minimizes CPU usage. Monitor CPU usage in Xcode Instruments. |
"This algorithm uses too much CPU"
"CPU usage spikes when processing images" "Optimize for better CPU performance" |
CRUD | Create, Read, Update, Delete - The four basic operations for persistent storage. Fundamental operations in database and API interactions. Most apps perform CRUD operations on data. Maps to HTTP methods (POST, GET, PUT, DELETE) in REST APIs. Essential concept in data management. |
"Implement CRUD operations for user data"
Create: Add new item Read: Fetch items Update: Modify item Delete: Remove item |
CSV | Comma-Separated Values - A simple file format for storing tabular data. Each line is a row, commas separate columns. Easy to read and write programmatically. Common for data import/export. Can be opened in spreadsheet apps. Simple alternative to databases for small datasets. |
name,age,city
Alice,25,NYC Bob,30,LA "Import CSV file" "Export data to CSV" |
DRY | Don't Repeat Yourself - A software development principle that promotes code reusability. Avoid duplicating code - extract common functionality into reusable functions or components. Reduces bugs, makes maintenance easier. If you find yourself copying code, consider extracting it. Use functions, extensions, and modifiers to stay DRY. |
// Instead of repeating button style code:
Button("Save") { }.buttonStyle(PrimaryButtonStyle()) // Create reusable style struct PrimaryButtonStyle: ButtonStyle { } |
GIT | Not an acronym, but often written in caps - A distributed version control system for tracking code changes. Essential for collaboration and code history. Xcode has built-in Git support. Allows you to commit changes, create branches, and revert mistakes. Works with GitHub, GitLab, Bitbucket. Every developer should learn Git basics. |
"Commit your changes with Git"
"Create a Git branch for new features" "Push to GitHub repository" |
GPU | Graphics Processing Unit - Specialized processor for rendering graphics and visual effects. Handles animations, 3D graphics, and visual effects in apps. SwiftUI animations use the GPU. Metal framework provides direct GPU access. Efficient use of GPU ensures smooth 60fps animations. |
"GPU acceleration for animations"
"This game requires a powerful GPU" "GPU rendering in Metal" |
HTTP | Hypertext Transfer Protocol - The protocol used for transmitting data over the web. Defines how messages are formatted and transmitted. Apps use HTTP to communicate with web servers and APIs. HTTPS is the secure version (encrypted). Request methods include GET, POST, PUT, DELETE. |
"Make an HTTP request"
"HTTP status code 200 (success)" "HTTP headers and body" |
IDE | Integrated Development Environment - A software application that provides comprehensive tools for software development. Xcode is Apple's IDE for iOS/Mac development. Combines code editor, compiler, debugger, and interface builder. Makes development more efficient with integrated tools. |
"Xcode is the IDE for iOS development"
"Configure your IDE settings" "Visual Studio Code is a popular IDE" |
iOS | iPhone Operating System - Apple's mobile operating system for iPhone and iPod Touch. Currently at iOS 17 (as of 2024). Provides frameworks, services, and technologies for app development. Updates annually with new features. Must target minimum iOS version when developing apps. |
"This app requires iOS 15 or later"
"iOS SDK and frameworks" "Test on different iOS versions" |
JSON | JavaScript Object Notation - A lightweight data format for storing and transmitting data. Human-readable text format with key-value pairs. Extremely common for web APIs and data storage. Swift has built-in support for encoding/decoding JSON. Uses curly braces and square brackets for structure. |
{"name": "Alice", "age": 25}
"Parse JSON from the API" "JSONDecoder in Swift" |
macOS | Mac Operating System - Apple's desktop operating system for Mac computers. SwiftUI apps can run on both iOS and macOS with minimal changes. Current version is macOS Sonoma. Shares many frameworks with iOS but has unique features. Allows building universal apps. |
"Build for macOS using SwiftUI"
"macOS-specific features" "Target iOS and macOS" |
MVC | Model-View-Controller - A software architecture pattern that separates application into three components. Model: data. View: UI presentation. Controller: mediates between Model and View. Traditional pattern in iOS development with UIKit. SwiftUI makes MVVM more natural, but MVC still relevant. |
"UIKit uses MVC architecture"
"The controller updates the view" "MVC vs MVVM patterns" |
MVVM | Model-View-ViewModel - A software architecture pattern that separates UI from business logic. Model: data and business logic. View: the UI (SwiftUI views). ViewModel: connects Model and View, holds UI state. SwiftUI works great with MVVM. Promotes clean, testable code separation. |
// Model
struct User { } // ViewModel class UserViewModel: ObservableObject { } // View struct UserView: View { } |
OS | Operating System - The software that manages hardware and provides services for applications. iOS, macOS, watchOS, tvOS are Apple's operating systems. Provides fundamental services: memory management, file system, networking, security. Apps run on top of the OS. Updates bring new features and APIs. |
"iOS is the mobile OS"
"OS version compatibility" "Check OS version before using new APIs" |
RAM | Random Access Memory - Temporary memory used by apps for active data. Apps use RAM to store data while running. iOS aggressively manages RAM, terminating apps when memory is low. Memory leaks waste RAM. Instruments helps detect memory issues. Different iPhone models have different amounts of RAM. |
"This app uses 200MB of RAM"
"Memory leak causing high RAM usage" "Optimize RAM consumption" |
REST | Representational State Transfer - An architectural style for designing networked applications. RESTful APIs use HTTP methods to perform CRUD operations (Create, Read, Update, Delete). Most web APIs follow REST principles. Uses standard HTTP methods and JSON for data. Clean, standardized approach to web services. |
"This is a RESTful API"
"GET /users (REST endpoint)" "REST architecture principles" |
SDK | Software Development Kit - A collection of tools, libraries, documentation, and APIs for developing software for a specific platform. Xcode includes the iOS SDK. Provides everything needed to build apps for a platform. Contains frameworks, simulators, and development tools. |
"Download the iOS SDK"
"The Firebase SDK for analytics" "SDK documentation" |
SF | San Francisco (in context of SF Symbols) - Apple's system font family and icon set. SF Symbols provides thousands of icons that match the SF font. Free to use in iOS apps. Automatically adapt to text size and weight. Available through the SF Symbols app. Essential resource for iOS iconography. |
Image(systemName: "star.fill") // SF Symbol
Text("Hello").font(.system(size: 16)) // SF font |
UI | User Interface - The visual elements and interactive components that users see and interact with in an app. Includes buttons, text, images, layouts, and all visual design. SwiftUI is a framework for building UIs. Good UI is intuitive, attractive, and responsive. |
"The app has a clean UI"
"SwiftUI makes building UIs easier" "UI design principles" |
URL | Uniform Resource Locator - An address that specifies the location of a resource on the internet. Used to fetch data from web servers or access files. In iOS, URL is a type for representing URLs. Essential for networking and web content. Includes protocol, domain, and path. |
https://api.example.com/data
URL(string: "https://google.com") "Invalid URL format" |
UX | User Experience - The overall experience and satisfaction a user has when using an app. Encompasses usability, accessibility, performance, and emotional response. Good UX means the app is easy, pleasant, and efficient to use. Broader than UI - includes the entire user journey. |
"This app has excellent UX"
"We need to improve the UX of the checkout flow" "UX research and testing" |
WWDC | Worldwide Developers Conference - Apple's annual developer conference where new technologies, frameworks, and OS versions are announced. Sessions teach new features and best practices. SwiftUI was announced at WWDC 2019. Major source of learning and news for iOS developers. Usually held in June. |
"iOS 17 was announced at WWDC 2023"
"Watch WWDC sessions to learn new features" "WWDC keynote" |
XML | eXtensible Markup Language - A markup language for storing and transporting data. Uses tags similar to HTML. More verbose than JSON but self-describing. Used in some APIs and file formats. Less common than JSON in modern iOS development. Requires XML parser to use. |
<user>
<name>Alice</name> <age>25</age> </user> "Parse XML response" |
This guide covers the fundamentals, but there's always more to discover in SwiftUI and iOS development.
Practice building projects, experiment with these concepts, and don't be afraid to make mistakes - that's how you learn best!