A collection of ideas, discoveries, and practical guides from my journey with Swift and iOS.

2026127 articles

Diagnosing Slow Requests and Excessive Network Usage Reading URLSessionTaskMetrics Verifying Contracts Against a Controlled Server Testing Status Codes, Invalid Payloads, and Transport Errors Isolating HTTP Fixtures with URLProtocol Streaming Responses and Incremental Parsing WebSockets: Connection State and Reconnection Background Transfers and App Relaunch Download Progress, Resuming, and Temporary Files Uploading Files and Multipart Form Data Coalescing Duplicate Requests and Rejecting Stale Results Offline Behavior and Reachability Assumptions HTTP Caching with Cache-Control and ETag Retry Policies, Backoff, and Idempotency Timeouts, Cancellation, and Request Lifetimes Redacting Sensitive Data from Network Logs Handling Logout During an In-Flight Request App Transport Security and TLS Trust Refreshing Credentials Without Duplicate Requests Authentication Headers and Credential Scope Designing an API Client Around Consumer Needs Pagination: Page Numbers, Cursors, and Stable Ordering Validating Decoded Data Before It Reaches the UI Decoding JSON with Codable: Keys, Numbers, Dates, and Failure Building Typed Endpoints and Request Bodies in Swift Separating Transport Errors from Application Failures Requests and Responses with async and await in URLSession Choosing a URLSession Configuration URLs, Query Parameters, and Percent Encoding in Swift HTTP Methods, Status Codes, and Headers: What URLSession Puts on the Wire Profiling Task Lifetimes and Main-Actor Contention in Swift Finding Data Races in Swift with Thread Sanitizer Avoiding Deadlocks and Blocking Waits in Swift Concurrency Testing Concurrent Swift Code with Controlled Interleavings Rejecting Stale Results After Request Replacement in Swift Combine vs. the Observation Framework in SwiftUI Continuation Ownership, Cancellation, and Double Resume in Swift Bridging Publishers to async/await with .values Combine vs. async/await and AsyncSequence Bridging Callback APIs with Checked Continuations in Swift Testing Publishers Buffering, Backpressure, and Stream Termination in Swift Debugging Pipelines with print and handleEvents Managing Resources: share and Multicasting Building Streams with AsyncStream and AsyncThrowingStream in Swift Schedulers: receive(on:) and subscribe(on:) Consuming Values with AsyncSequence in Swift Error Handling: catch, retry, and replaceError Notifications as Publishers Migrating to Swift 6 Data-Race Safety Key-Value Observing with Publishers Choosing an Executor in Swift Without Blocking the UI Timers Networking with URLSession Publishers Isolated and Nonisolated Methods in Swift Sequence Operators: first, last, and collect Sendable in Swift: Moving Values Across Isolation Boundaries Time: debounce, throttle, and delay Combining: combineLatest, zip, and merge The Main Actor and UI-Facing State in Swift Filtering: filter, removeDuplicates, and compactMap Actor Reentrancy in Swift: Keeping Invariants Across Suspension Points Transforming: map, flatMap, and scan AnyCancellable and Memory Management Actors in Swift: Protecting State Behind an Isolation Boundary @Published Properties Task Priority, Inheritance, and Priority Inversion in Swift Subjects: PassthroughSubject and CurrentValueSubject sink and assign Unstructured and Detached Tasks in Swift: When to Use Each Publishers, Subscribers, and Subscriptions Cancellation Handlers and Reliable Resource Cleanup in Swift Cooperative Cancellation and Cancellation Checks in Swift Task Groups in Swift: Fan-Out, Aggregation, and Early Exit Creating Tasks and Choosing Their Lifetime Owner in Swift Structured Concurrency and Child-Task Lifetimes in Swift Running Independent Work with async let in Swift Suspending Functions with async and await in Swift Threads, Dispatch Queues, and Swift Tasks: Three Layers of Concurrent Work Concurrency vs. Parallelism in Swift: Understanding the Difference Testing with RxTest and RxBlocking Writing Custom Reactive Extensions MVVM with RxSwift RxCocoa: Binding Observables to UIKit Schedulers: observe(on:) and subscribe(on:) Error Handling: catch, catchAndReturn, and retry Combining Operators: combineLatest, zip, merge, concat, withLatestFrom Transforming Operators: map, flatMap, flatMapLatest, concatMap Time Operators: debounce, throttle, delay, interval, timer, timeout Filtering Operators: filter, distinctUntilChanged, skip, take Driver and Signal Single, Maybe, and Completable Relays: PublishRelay and BehaviorRelay AsyncSubject ReplaySubject BehaviorSubject PublishSubject Disposing and DisposeBag Subscribing Creating Observables: just, of, from, and create Observables and Observers LLDB Survival Guide: Theory, Tricks, and Python Hooks Profiling Sensor Work and Battery Usage Stopping Updates When a Feature Ends Testing Unavailable Hardware and Denied Permissions Injecting Recorded Sensor Data for Deterministic Tests Designing Features Around Uncertainty and Accuracy Distinguishing Missing Data from a Valid Zero Reading Combining Motion and Location Without Shared-State Races Timestamps, Stale Samples, and Out-of-Order Events Background Location and App Lifecycle Boundaries Geocoding, Reverse Geocoding, and Request Limits Visits and Significant Location Changes Region Monitoring and Geofencing Heading, Compass Calibration, and Magnetic Interference Distance Filters and Energy-Aware Tracking Location Updates and Accuracy Requirements Sampling Rates, Noise, Filtering, and Drift Altitude, Pressure, and Relative Measurements Pedometer Data and Activity Recognition Attitude, Reference Frames, and Coordinate Conversion Device Motion, Gravity, and User Acceleration Accelerometer and Gyroscope Measurements Device Testing vs. Simulator Capabilities Handling Permission Changes and Reduced Accuracy Requesting Motion and Location Permissions in Context Checking Sensor Availability Before Starting Work

202523 articles

Phantom Types in Swift Linear Programming in Swift: Model Constraints and Solve Small Two-Variable Problems Setting Up a New macOS Device: My Essential Tweaks Parallel Algorithms and MapReduce in Swift: Partition, Isolate, and Combine The Fourier Transform in Swift: DFT, Radix-2 FFT, and Sampling Cryptographic Algorithms in Swift: SHA-256, X25519, and Derived Keys Three-Tier Architecture in Swift: Presentation, Use Cases, and Data Boundaries Merkle Trees in Swift: Commitments, Inclusion Proofs, and Canonical Encoding Front Controller in Swift: Validate and Dispatch Incoming Requests in One Place HyperLogLog in Swift: Estimate Distinct Counts and Merge Compatible Sketches When Protocols Are Overkill in Swift Service Locators and Registries in Swift: Resolution, Scope, and Hidden Dependencies Bloom Filters in Swift: Probabilistic Membership with an Error Budget Performance Considerations for Protocol-Oriented Swift Repository in Swift: Domain Contracts, Cache Policy, and Consistent Writes Inverted Indexes in Swift: Tokenization, Posting Lists, and Boolean Search Migrating Swift Architectures: One Writer, Stable Contracts, and Incremental Cutovers Refactoring a Swift Class Hierarchy into Protocols Coordinator in Swift: Navigation, Child Flows, and Ownership Dynamic Programming in Swift: State, Recurrences, and Reconstructing Decisions UIKit and SwiftUI Architecture: Preserve Ownership Across the Framework Boundary Specification in Swift: Compose Rules with Clear Evaluation Semantics Build a Small Reading-List App with Protocol-Oriented Swift

202465 articles

Using SwiftGraph in Swift: Model the Problem and Verify Library Semantics Architecture and Testability in Swift: Deterministic Boundaries and Useful Evidence Factories in Protocol-Oriented Swift: Construct the Right Capability Null Object in Swift: An Explicit No-Op Policy Instead of Missing Behavior Minimum Spanning Trees in Swift: Kruskal, Union-Find, and Cut Safety Clean Code in Swift Choosing a Swift Architecture from State, Team Boundaries, and Change Pressure Swift Evolution: How the Language Changes The Observer Pattern in Swift: Subscriptions, Ordering, and Cancellation Visitor in Swift: Double Dispatch, New Operations, and the Closed Node Set Swift Package Manager: A Practical Guide Operation and OperationQueue in Swift A* Pathfinding in Swift: Heuristics, Reopening, and Optimality Swift Concurrency: async/await, Tasks, and Actors Lasso in Swift: Screen State, Actions, Outputs, and Flow Ownership Macros in Swift Designing Error Handling Around Swift Protocols Template Method in Swift: Fix the Algorithm and Expose Narrow Hooks Nested Types in Swift Swift Test Coverage, Test Plans, and CI Shortest Paths in Swift: Dijkstra, Bellman-Ford, and Weight Assumptions Error Handling in Swift Typed Throws in Swift 6: Carry Error Types Through Protocols The Composable Architecture in Swift: Reducer Composition, Dependencies, and Effects State in Swift: Make Transitions and Legal Operations Explicit Zombies In Swift Breadth-First Search in Swift: Layers, Shortest Hops, and Multi-Source Search The Elm Architecture in Swift: Model, Update, View, and Described Effects Memento in Swift: Restore Owned State Through Opaque Snapshots Depth-First Search in Swift: Paths, Cycles, and Topological Order Redux-Style Architecture in Swift: Pure Reducers and an Ordered Store Reliable UI Testing in Swift Mediator in Swift: Coordinate Colleagues Without a Web of Callbacks Graphs in Swift: Vertices, Edges, and Representation Contracts Functors, Applicative Functors, and Monads in Practical Swift RIBs at Scale: Feature Ownership, Plugin Boundaries, and Session Cleanup Command in Swift: Model Actions, Undo, and Redo as Explicit Operations Tries in Swift: Prefix Search, Deletion, and Unicode Policy A Functional Spreadsheet App in Swift: Formulas, Dependencies, and Cycles RIBs in Swift: Business Lifetimes, Child Routing, and Dependency Scopes Chain of Responsibility in Swift: Explicit Handling, Rejection, and Fallthrough Integration Testing in Swift: Networking and Storage Splay Trees in Swift: Move Accessed Keys to the Root Parser Combinators in Swift: Build a Grammar from Small Functions When Architecture Structure Pays Off: Change Cost, Contracts, and Evidence Publisher-Subscriber in Swift: Typed Events, Queued Delivery, and Subscription Lifetime Mixing Object-Oriented and Functional Programming in Swift AVL Trees in Swift: Rotations, Cached Heights, and Logarithmic Search Building Diagrams with Functions in Swift: A Small Layout Language Clean Swift in Swift: Request, Response, and View Model Through the VIP Cycle How to Avoid Flaky Tests in Swift Proxy in Swift: Control Access, Loading, and Cache Validity Common Object-Oriented Anti-Patterns in Swift Heaps and Priority Queues in Swift: Maintain the Next Best Item VIPER in Swift: A Complete Use Case Across Five Roles Lazy Sequences in Swift: Deferred Work, Repeated Work, and Bounded Results Flyweight in Swift: Share Immutable Intrinsic State Without Sharing Edits Network Issues in MacBooks with Silicon Chips and Proposed Solutions The Law of Demeter in Swift: Reduce Knowledge of Object Internals Binary Trees in Swift: Shape, Traversal, and Expression Evaluation Iterators and Sequences in Swift: Pull Values Without Assuming Replay Clean Architecture in Swift: Dependency Direction and Honest Use-Case Boundaries Testing Asynchronous Swift Code Facade in Swift: Give a Use Case One Coherent Entry Point Dependency Injection in Swift Without a Container

202387 articles

Quicksort in Swift: Three-Way Partitioning and Duplicate Keys Persistent Binary Search Trees and Tries in Swift MVVM in SwiftUI: Observable State, View Identity, and Async Work Decorator in Swift: Add Behavior While Preserving the Capability Contract Swift Interoperability with Objective-C, C, and C++ The SOLID Principles in Swift: Boundaries That Survive Change Reflection in Swift with Mirror Stable Merge Sort in Swift: Divide, Merge, and Account for Storage Key-Value Observing (KVO) in Swift Purely Functional Data Structures in Swift: Persistent Lists and Queues MVVM with Coordinators in Swift: Typed Outputs and Owned Navigation Flows Composite in Swift: Treat Leaves and Groups Through One Honest Contract Property Wrappers in Swift Protocol Inheritance in Swift: Refine Capabilities Without Sharing Storage Extensions in Swift Deep Copy vs. Shallow Copy in Swift Selection Sort in Swift: Minimum Selection and the Cost of Writes Access Control in Swift Test Doubles In Swift Property-Based Testing in Swift: Generators, Shrinking, and Reproducible Failures Data Binding in Swift: Closures, Combine, and Observation Have Different Contracts Deinitialization in Swift Primary Associated Types in Swift: Keep the Useful Type Information Bridge in Swift: Separate Two Independent Axes of Variation Enumerations in Swift Equality, Identity, and Hashable in Swift Insertion Sort in Swift: Sorted Prefixes and Nearly Sorted Input Control Flow in Swift: if, guard, switch, and Loops Value Types and Copy-on-Write in Swift: Independence Without Eager Copies MVVM in Swift: State Projection, User Intent, and Request Identity Associated Types in Swift: Preserve Relationships Between Capabilities Adapter in Swift: Translate Contracts Without Hiding Meaning Delegation in Swift: One Object Reporting to Another Bubble Sort in Swift: Inversions, Early Exit, and a Correctness Invariant The Value of Immutability in Swift: Stable Facts and Explicit Changes Choosing MVP in Swift: Presentation Rules, View Contracts, and Integration Cost Constrained Protocol Extensions in Swift: Make the Requirement Visible Monostate in Swift: Separate Instances with One Shared State Composition Over Inheritance in Swift iOS Accessibility Basics Comparing Sorting Algorithms in Swift: Stability, Memory, and Real Workloads Enumerations and Algebraic Data Types in Swift: Make Invalid States Harder to Build MVP in Swift: A Passive View and an Explicit Presentation Contract Default Implementations in Swift Protocol Extensions Lazy Initialization in Swift: Deferred Work, Failure, and Concurrency Parent and Child Classes in Swift: Inheritance vs. Ownership Queues in Swift: FIFO Without Repeated Array Shifts ModelAdapter-ViewBinder in Swift: Explicit Bindings and Disposable Lifetimes Optionals as a Functional Tool in Swift Object Pools in Swift: Bounded Resources, Leases, and Reliable Return Class-Only Protocols in Swift: AnyObject and Ownership Protocols Instead of Multiple Inheritance in Swift Stacks in Swift: LIFO State, Balanced Delimiters, and Undo SwiftUI View Values, Identity, and State: Avoiding Common Bugs compactMap and flatMap in Swift: Missing Values, Nested Values, and Lost Errors MVC with Coordinators in Swift: Navigation Policy and Screen Lifetime Adopting Swift Protocols in Structs, Enums, and Classes Prototype in Swift: Copying Values, Cloning Objects, and Preserving Identity Rules Protocols Instead of Abstract Classes in Swift Hash Tables in Swift: Collisions, Resizing, and Stable Key Contracts map, filter, and reduce in Swift: Choose the Operation That Matches the Result MVC with View State in Swift: Separate Document Facts from Interaction State Property and Method Requirements in Swift Protocols Builder in Swift: Assemble Configuration Without Publishing Invalid State Type Properties and Methods in Swift: static vs. class Analyzing Swift Algorithms: From a Slow Screen to a Defensible Cost Model Higher-Order Functions in Swift: Reusable Policies and Honest Effects Refactoring Massive View Controllers in Swift Around Real Responsibilities Abstract Factory in Swift: Construct Compatible Families of Capabilities OOP vs. POP in Swift: Two Ways to Share Behavior FIRST Principles for Reliable Swift Tests final in Swift: Closing Inheritance Deliberately Big O in Swift: Bounds, Growth Rates, and Amortized Work Wrapping Core Image Filters in Swift Functions MVC in Swift: Where Simplicity Helps and Coupling Starts to Hurt Factory Method in Swift: A Stable Workflow with a Construction Hook The Limits of Class Inheritance in Swift Method Overloading in Swift: Let the Call Site Explain the Choice This Is Why I Don't Prefer Git GUI Tools Time and Space Complexity in Swift: Count Work, Copies, and Live Storage Why I Prefer To Store My Files On A Digital Ocean Space & Not Google Drive Or Dropbox. From Imperative to Declarative Swift Without Losing the Algorithm MVC in Swift: Model Rules, View Rendering, and Controller Coordination Gentle Introduction To Unit Testing. An OOP Refresher Before Protocol-Oriented Swift Singleton in Swift: Shared Identity, Initialization, and Hidden Dependencies Overriding Methods and Properties in Swift

202226 articles

Pure Functions and Side Effects in Swift: Build a Testable Core Designated and Convenience Initializers in Swift Thinking Functionally in Swift: Functions as Values Refresher: Solving Few Problems Initializers and Deinitializers: The Lifetime of a Swift Object RunLoop Explained for Swift Developers Opaque and Boxed Types in Swift: some vs. any Generics in Swift Polymorphism in Swift: One Interface, Different Behavior Protocols in Swift Capture Lists in Swift Closures Abstraction in Swift: Designing Interfaces Around Intent Encapsulation in Swift: Protecting Valid State Reading and Drawing UML Class Diagrams for Swift Value Types vs. Reference Types in Swift: Choosing Ownership Thinking in Objects: Modeling a Domain in Swift Static vs. Dynamic Dispatch in Swift Type Casting in Swift iOS/Android Developer Security Basics Understanding GPS Hardware Basics for Mobile Developers Swift Sets: Basics and Practical Examples Using unicode markers (LTR: 0x200E, RTL:200F) to align "hybrid RTL/LTR strings" correctly. Mastering Swift Bitwise Operators: Theory and Practical Examples Easily Tiling Images in Interface Builder Without Code Why my 0.3 MB image occupies around 10 MB on RAM? Why You Should Never Use Floating-Point or Double Data Types for Money Calculations!

202134 articles

ABI Stability in Swift Finding Memory Bugs with Address Sanitizer Understanding Optionals in Swift: Handling Absence of Data Safely Swift: The Difference Between Void and () Swift: The Difference Between nil, Nil, NULL, NSNull Understanding Swift: Differences Between Any, AnyObject, and AnyHashable Swift Root/Base Class & NSObject: A Quick Look Swift's Basic Data Types & Type Inference Understanding Swift Variables and Constants: A Dive into Mutability Mastering Swift Style Guides: Elevate Your Code to the Next Level Swift Lexical Structure Swift Reserved Keywords, with brief explanations. Strings and Characters That Don’t Bite Operators You Actually Use Advantages of Swift Over Objective-C What is Swift Programming Language? stride in Swift Escaping and Non-Escaping Closures in Swift defer in Swift Method Swizzling in Swift Advanced and Custom Operators in Swift Optional Chaining in Swift Memory Safety in Swift: Exclusive Access Automatic Reference Counting (ARC) in Swift Initialization in Swift Inheritance in Swift Subscripts in Swift Methods and mutating in Swift Properties in Swift Structures and Classes in Swift: Value vs. Reference Types Closures in Swift Functions in Swift Pattern Matching in Swift Arrays and Dictionaries in Swift