Skip to content
tezvyn:

Swift

201 bites tagged Swift — interview questions with model answers, and 60-second explainers.

iOS & Swift2 min read

The Responder Chain: Who Handles That Tap?

The Responder Chain is iOS's chain of command for events. When a user taps the screen, the event travels up a view hierarchy, asking each object, "Can you handle this?" until one accepts. Accidentally breaking this chain can silently kill event handling.

iOS & Swift2 min read

SwiftUI State and Binding: Owning vs. Sharing Data

In SwiftUI, `@State` is owning the data, while `@Binding` is borrowing a key. A view uses `@State` for its private source of truth, like a toggle's status, and passes a `@Binding` to child views so they can modify the original source.

iOS & Swift1 min read

UICollectionView: Grids, Stacks, and Custom Layouts

UICollectionView is a powerful tool for displaying items in customizable layouts, going far beyond a simple vertical list. Use it for photo galleries or App Store-style interfaces.

iOS & Swift2 min read

UITableView: The Backbone of iOS Lists

UITableView is the workhorse for displaying scrolling lists in iOS. It's used everywhere from Settings to Contacts. The footgun is forgetting to reuse cells, which causes massive memory usage and choppy scrolling, so always dequeue a reusable cell.

iOS & Swift2 min read

SwiftUI's View: A Blueprint, Not a Building

A SwiftUI View is a lightweight blueprint for a piece of your UI, not the UI element itself. It's used to compose everything from a single button to an entire screen. The common mistake is treating it like a heavy `UIView` class; it's a cheap.

iOS & Swift2 min read

UIStackView: Layouts Without Manual Constraints

A UIStackView is an invisible container that arranges views in a single column or row, saving you from writing manual layout constraints. It's ideal for toolbars or forms. The main footgun is forgetting it's non-rendering—you can't set its background color.

iOS & Swift2 min read

The UIViewController Lifecycle: From Creation to On-Screen

Think of a UIViewController as an actor with cues to enter, perform, and exit. Its lifecycle methods are your script for setting up data, updating the UI, and cleaning up resources.

iOS & Swift2 min read

UIView: The Building Block of iOS UIs

A UIView is the fundamental building block for iOS UIs. Think of it as a rectangular canvas for drawing content, handling touches, or containing other views. You use it everywhere, from simple buttons to complex layouts.

iOS & Swift2 min read

Hunt Retain Cycles with the Memory Graph Debugger

Xcode's Memory Graph Debugger is a visual map of your app's live objects and their relationships. Use it to hunt down memory leaks, especially retain cycles where objects won't deallocate.

iOS & Swift2 min read

iOS Provisioning Profiles: Your App's Passport

A provisioning profile is a passport for your iOS app, bundling who can run it (devices), what it can do (entitlements), and who built it (certificate). It's required for running on physical devices and is a common source of build errors.

iOS & Swift2 min read

Swift Package Manager: Native Dependency Management

Swift Package Manager (SPM) is Apple's built-in librarian for your project's code dependencies. You use it to add, remove, and update third-party libraries directly in Xcode. The main footgun is that version conflicts between dependencies can break your build.

iOS & Swift2 min read

LLDB: Stop Time with Breakpoints

A breakpoint is a red light for your code, pausing execution at a specific line so you can inspect your program's state. In Xcode, use it to freeze your app when a bug occurs, examine variables, and step through code.

iOS & Swift2 min read

Auto Layout: Describing Relationships, Not Frames

Auto Layout lets you describe a UI by its relationships, not hardcoded coordinates. You declare "this button is centered and 8 points below the logo," and the system calculates its position.

iOS & Swift2 min read

Xcode Schemes vs. Build Configurations

Schemes are *what* you build (the target and action), while Configurations are *how* you build (the settings). Use them to manage environments like Debug vs. Release, each with its own API keys. The footgun is putting environment settings directly in a Scheme.

iOS & Swift2 min read

Asset Catalogs: Your App's Smart Media Library

An Asset Catalog is a smart folder for your app's visuals, automatically serving the right version (like high-res or dark mode) for the user's device. It's the standard way to manage images, icons, and colors in Xcode.

iOS & Swift2 min read

Interface Builder: Visual UI Design for iOS/macOS

Interface Builder is Xcode's visual editor for building UIs. You drag-and-drop components like buttons and screens, which are saved as `.xib` files. It's used to quickly lay out app screens without writing UI code.

iOS & Swift2 min read

Xcode Project: Your App's Blueprint and Toolbox

An Xcode project is a self-contained kit for your app, holding all files, assets, and build instructions. It's the central repository for source code, build settings, and dependencies. The footgun: moving files in Finder without telling Xcode breaks builds.

iOS & Swift2 min read

Opaque Types: Hide Implementation, Not Capabilities

Opaque types (`some Protocol`) hide a function's concrete return type, exposing only its protocol conformance. This lets you change the implementation later (e.g., from `ReverseCollection`) without breaking client code that just needs `some Collection`.

iOS & Swift2 min read

Key-Path Expressions: Type-Safe Pointers to Properties

A key path is a type-safe "pointer" to a property, like `\User.name`. It lets you pass around a reference to a property itself, not just its value, making it ideal for generic sorting or SwiftUI data binding. The footgun is forgetting they are strictly typed.

iOS & Swift2 min read

Associated Types: Making Protocols Generic

Associated types make protocols generic. Think of them as a "fill-in-the-blank" type name. A protocol like `Sequence` has an `Element` type, which a conforming `Array<String>` fills in as `String`.

iOS & Swift2 min read

Copy-on-Write (CoW) in Swift

Copy-on-write lets Swift's Array, Dictionary, Set, and String share one underlying buffer across copies until one is mutated, giving full value-type semantics with the performance of sharing, deferring the actual copy until it is truly needed.

iOS & Swift2 min read

Retain Cycles and Capture Lists in Swift

A retain cycle is a memory leak where two objects hold strong references to each other, preventing deallocation. This often happens in closures that capture `self`, like network callbacks.

iOS & Swift2 min read

Protocol Extensions: Default Behavior for Free

Protocol extensions give conforming types default functionality "for free," like a standard toolkit with every blueprint. Use them to add common behavior to your protocols or even extend system types.

iOS & Swift2 min read

The Result Type: Modeling Success and Failure

The Result type is a sealed box for an operation's outcome: it holds either a success value or a failure error. It's used in asynchronous code like network requests to create clean, explicit completion handlers. The footgun is forgetting to handle both cases.

Get Swift bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.