Skip to content
tezvyn:

Swift

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

iOS & Swift2 min read

The Animatable Protocol

The Animatable protocol lets a custom SwiftUI view or Shape expose its state as interpolatable data, so SwiftUI can smoothly tween between values across frames instead of snapping, which is how custom shapes and progress indicators get real animation.

iOS & Swift2 min read

CATransaction: Grouping Core Animation Changes

Think of CATransaction as an atomic 'commit' for UI animations, grouping layer property changes to appear at once. Use it to synchronize animations or set a custom duration for a batch of changes.

iOS & Swift2 min read

CAKeyframeAnimation: Animating Through Key States

CAKeyframeAnimation defines animations with waypoints, not just a start and end. Think of it as a flipbook where you set key frames and the system interpolates. Use it for complex paths, like shaking an icon. Footgun: setting both `path` and `values`.

iOS & Swift2 min read

Creating Custom Gestures by Subclassing UIGestureRecognizer

Subclassing UIGestureRecognizer lets you build a custom state machine for touch events. Use it for unique interactions like a rotary dial. The footgun is state management: you must explicitly update the gesture's state or it will never be recognized.

iOS & Swift2 min read

CAShapeLayer: Hardware-Accelerated Vector Drawing

A CAShapeLayer is a GPU-powered stencil for drawing vector shapes. It renders paths like lines and curves far more efficiently than drawing in `draw(_:)`. Use it for custom UI like progress rings.

iOS & Swift2 min read

CABasicAnimation: Simple Property Changes Over Time

CABasicAnimation animates a single layer property from a start to an end value. Use it for fading a view (opacity), moving it (position), or scaling it (transform).

iOS & Swift2 min read

UIBezierPath: Drawing Custom Shapes in Code

UIBezierPath is a digital pen for drawing custom shapes. You define a path with lines and curves, then fill or stroke it. It's essential for custom charts, icons, or non-rectangular views.

iOS & Swift2 min read

TaskGroup: Dynamic, Structured Concurrency in Swift

A TaskGroup is like a manager for parallel jobs. You add a dynamic number of tasks, and it runs them concurrently, ensuring the parent task waits for them all. Use it to fetch multiple images or API data.

iOS & Swift2 min read

URLSessionDownloadTask: Download Files Without Hogging Memory

URLSessionDownloadTask downloads files directly to disk, not memory, making it ideal for large assets. Use it for videos or updates, especially in the background. The footgun: you must move the file from its temporary location or the OS will delete it.

iOS & Swift2 min read

AsyncSequence: A Sequence That Awaits Its Next Element

AsyncSequence is like a regular Swift Sequence, but you `await` its next element. It lets you process values that arrive over time, like network data, without blocking. The footgun: iteration suspends, so run it in a `Task` for true concurrency.

iOS & Swift2 min read

MainActor: Keep Your UI on the Main Thread

The MainActor is a global actor ensuring code runs on the main thread, the only safe place for UI updates. Use it when modifying UIKit or SwiftUI views. The footgun is over-applying it to a whole class, which can serialize background work and freeze the.

iOS & Swift2 min read

HTTPURLResponse: Reading the Server's Reply

Think of HTTPURLResponse as the envelope for a server's reply. It holds metadata like the status code (200 OK, 404 Not Found) and headers. You'll handle this after every URLSession call to check if your request succeeded.

iOS & Swift2 min read

URLSessionConfiguration: The Blueprint for Network Requests

Think of URLSessionConfiguration as a blueprint for your network sessions. It defines rules like timeouts and caching policies upfront. Use it to create customized sessions, but remember you can't change the configuration after the session is created.

iOS & Swift2 min read

Swift Task

Task is the unit of concurrent work in Swift's structured concurrency model. Creating a Task starts an async job right away, and Swift tracks its priority, cancellation, and lifetime automatically instead of leaving you to manage threads by hand.

iOS & Swift2 min read

JSONEncoder: Turning Swift Objects into JSON

JSONEncoder is your app's translator, converting Swift objects into JSON data for APIs. It's the "serialization" half of Codable. Use it to send data to a server or save objects. The footgun: mismatched keys or date formats require configuring the encoder.

iOS & Swift2 min read

JSONDecoder: Turning JSON into Swift Types

JSONDecoder is your translator for turning raw JSON data into native Swift structs or classes. It's the standard way to parse API responses, letting you work with typed, safe objects.

iOS & Swift2 min read

URLRequest: The Blueprint for a Network Call

URLRequest is the recipe for a network call, not the call itself. It bundles the URL, HTTP method, headers, and body. You hand this 'order form' to URLSession to execute. The footgun is thinking URLRequest sends the request—it only describes it.

iOS & Swift2 min read

URLSession: The Core of iOS Networking

URLSession is the engine for all network requests in Apple apps. Use it to fetch API data, download images, or upload files. The biggest footgun is blocking the main UI thread, which freezes your app; always perform network tasks asynchronously.

iOS & Swift2 min read

NSFetchedResultsController: The Bridge for Core Data & UI

NSFetchedResultsController is a bridge that automatically syncs a Core Data database with a UITableView. It efficiently manages data fetching, memory, and UI updates for dynamic lists, like a social feed.

iOS & Swift2 min read

Core Data Migrations: Evolving Your App's Schema Safely

Core Data migrations are your app's plan for evolving its local data model without losing user data. Use them when shipping a new version that adds or renames attributes. The footgun is assuming 'lightweight' migration works for everything; it doesn't.

iOS & Swift2 min read

NSPersistentContainer: Your Core Data Stack in One Object

NSPersistentContainer is a pre-built engine for Core Data, managing the model, coordinator, and context. It's the standard for iOS 10+ apps. The footgun is forgetting you can customize it or using its main `viewContext` for heavy background work, which blocks…

iOS & Swift2 min read

App Groups: Sharing Data Between Your Apps & Extensions

App Groups create a shared 'lockbox' for your apps and extensions on a user's device, bypassing the default app sandbox. Use it to share UserDefaults or files between your main app and its widget. The footgun: you must use specific APIs and manage data sync.

iOS & Swift2 min read

Realm Database

Realm is an object oriented mobile database that stores your Swift model objects directly, without an ORM layer translating to and from SQL, and gives you live objects that automatically update in your UI whenever the underlying data changes.

iOS & Swift2 min read

SQLite: A Database in a Single File

SQLite is a self-contained SQL database engine that lives in a single file. It's ideal for mobile apps needing fast, reliable local data storage without a server. The footgun is using it for high-concurrency write scenarios, where it becomes a bottleneck.

Get Swift bites daily.

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

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