Use inheritance when the subtypes share stored state and a genuine is-a relationship with a class whose behavior they extend. Use a protocol when unrelated types need to satisfy the same capability contract, when you need value-type conformance, or when you want composition without a fragile base class. Most large Swift codebases end up protocol-first with shallow class hierarchies reserved for framework integration.

Inheritance builds a single chain where a subclass receives stored properties, method implementations, and dispatch behavior from one superclass. A protocol declares requirements without implementation, and any type can adopt it independently of its lineage. The two solve different problems, and confusing them is the most common cause of rigid, hard-to-test object graphs.

How inheritance couples state and dispatch

A Swift or Objective-C class hierarchy allocates one object that carries every stored property from every ancestor. When you call a method, the runtime walks the vtable (Swift) or the method cache (Objective-C) from the most-derived class upward. That single-object layout is why inheritance is efficient and why it is rigid.

The mechanism matters because subclassing is not just about reusing code. It changes memory layout, initialization order, and dispatch. A subclass inherits the superclass's designated initializers, its deinit behavior, and its conformance to any protocols the superclass adopted. If the superclass later adds a stored property or a new required initializer, every subclass rebuilds.

Swift adds a specific hazard: a stored property added to a non-final class changes the class's size, which breaks binary compatibility for precompiled clients. That is why Swift library authors mark classes final or use resilience attributes. UIKit and AppKit ship as resilient Objective-C frameworks, which is a large part of why subclassing UIViewController has remained stable across OS releases.

Protocol dispatch works differently. A protocol requirement is satisfied by a witness table entry pointing to the conforming type's implementation. For a struct or enum, the witness records which method to call for that value type. For a class, the witness may be a direct or dynamic dispatch depending on final, open, and whether the method is in an extension.

The practical consequence is that protocol conformance is per-type, not per-hierarchy. A struct Temperature, an enum SensorState, and a final class Cache can all conform to Codable with zero shared ancestry.

Quantifying the difference

The numbers that matter are layout cost, dispatch cost, and the change radius when you edit a type.

A class instance on a 64-bit Apple platform carries at minimum a 16-byte object header in Objective-C (isa pointer plus refcount fields) before any subclass properties. Swift native classes carry a similar metadata pointer and refcount. Every additional stored property in the chain adds its size to each instance. A struct, by contrast, stores only its fields inline, with no per-instance header.

Dispatch cost is measured in nanoseconds per call, and the exact figure varies by CPU and cache state. What is stable and worth knowing: static dispatch through a struct or final class resolves at compile time and can inline. Protocol witness dispatch adds an indirect call. Objective-C objc_msgSend dispatch is fast but lands in a global method cache, which is why subclass overrides still cost something at call time.

The change radius is the metric developers feel. Editing a stored property on a class with 40 subclasses touches 40 types at build time. Adding a protocol requirement touches every conforming type once, and you can scope that blast radius by extending the protocol with default implementations.

Where each approach breaks down

Inheritance breaks when the hierarchy is shallow but wide. A BaseViewController with eight subclasses that override two methods each is a classic example: the base class accumulates flags, optional hooks, and if branches until it becomes a god object with no single responsibility.

Inheritance also breaks across module boundaries when the superclass is not designed for it. The fragile base class problem is real: a superclass author changing method ordering, adding a call inside an existing method, or altering initializer semantics can silently change subclass behavior. Apple's own guidance for UIViewController lifecycle ordering has shifted across iOS releases, which is why careful subclass authors call super in the documented position rather than assuming.

Protocols break differently. A protocol with 12 requirements that every conformer must implement exhausts the benefit of decoupling. A protocol used only for a single type is usually a premature abstraction. And protocols cannot hold stored state, so anything that needs persistent fields across methods needs either associated objects (Objective-C), a generic wrapper type, or a class that adopts the protocol.

A counterintuitive detail worth internalizing: protocol extensions with default implementations do not get dynamically dispatched to a conforming type's own method unless the method is also a protocol requirement. If you define func describe() -> String only in an extension, calling it through the protocol-typed value runs the default, even if the concrete type defines its own describe. That silent binding surprises many developers in their first year of Swift.

Misconceptions worth killing

The most common misconception is that protocols and inheritance are interchangeable ways to share code. They are not. Inheritance shares implementation and state along a single lineage. Protocols share a contract across arbitrary lineages. Code sharing between unrelated types comes from protocol extensions and composition, not from faking an is-a relationship.

The second misconception is that structs cannot be polymorphic. They can, through protocol-typed properties, generic constraints (<T: Shape>), and some/any existentials. Value types pass by copy, but a protocol reference to a struct works fine at the dispatch boundary.

The third is that class inheritance is faster. On modern Darwin platforms, the difference between a protocol witness call and a virtual class call is often within a few nanoseconds, and a well-placed final or a generically specialized protocol can eliminate dispatch entirely. Do not pick inheritance for performance unless a profiler tells you to.

Red flags that a hierarchy or protocol has gone wrong:

A base class has more than one optional hook method that subclasses override conditionally. A protocol has more than 8 requirements and more than one default implementation. Subclasses override a method only to call super and nothing else. A protocol exists with exactly one conformer that also inherits from the "obvious" class. You are using associatedtype on a protocol that is never used existentially. A base class stores UI or configuration state that only two subclasses actually read.

Comparison table

Dimension Class inheritance Protocol conformance
Shared stored state Yes, inherited across chain No, requires wrapper or associated object
Value type support No, classes only Yes, structs and enums conform
Multiple adoption Single superclass Unlimited protocols
Dispatch model Vtable or objc_msgSend Witness table or generic specialization
Change radius Every subclass Every conformer, scoped by extensions
Best fit Framework subclasses (UIKit, NSManagedObject) Capability contracts, dependency injection, test doubles
Binary stability Fragile if superclass is non-resilient Stable per conformance in user modules

Timeline: how a hierarchy ages

Stage Typical duration Symptom
Greenfield Days to weeks One base class, two subclasses, clean overrides
Growth Months Base class gains optional hooks and boolean flags
Divergence Months to a year Subclasses override the same method for unrelated reasons
Branching Year or more Conditional logic inside the base class keyed on subclass identity
Extraction Weeks if planned Protocol extracted from overridden surface
Retirement Weeks to months Base class becomes thin shell over protocol composition

The timeline is not inevitable, but it is common in team codebases. The extraction stage is where most teams miss the point: they extract a protocol but keep the base class as an implementation, and then the protocol gains a default implementation that silently re-couples behavior.

Practical rules for choosing

Start with a specific decision tree rather than a preference.

If the type must subclass a framework class (UIViewController, NSView, NSManagedObject), inherit from that class and adopt protocols for the extra capabilities you actually need. If the types share stored state and behavior on one lineage, use a class, but mark it final unless you can name the exact subclasses. If the types differ in lineage but share a capability, define a small protocol with 3 to 6 requirements and extend it for defaults. If you need to inject substitutes in tests, the dependency should be a protocol, not a base class. If a protocol reaches 8 or more requirements, split it into two protocols along the axis of what callers actually use. If a struct needs to satisfy a contract and no state must persist across methods, conform the struct; skip the class entirely.

One threshold worth setting explicitly: any base class you cannot mark final should have at least three committed subclasses, or you do not yet have a hierarchy—you have an abstraction waiting to calcify. Similarly, any protocol with fewer than two planned conformers is a design note, not architecture.

Limitations and what the evidence supports

Dispatch cost and memory overhead measurements depend on the compiler version, optimization level, and target architecture. Apple's published guidance on class design and protocol usage describes the mechanisms, not absolute performance numbers, so any figure quoted here is a mechanism-level estimate rather than a benchmark.

The rules above are heuristics, not guarantees. A well-designed single-subclass class is often correct when the subclass is genuinely a specialization. A protocol with one conformer is often correct when the conformer is a generated mock or a type that will gain siblings.

Change radius reasoning assumes you know your dependency graph. In modular codebases with @_implementationOnly or resilient APIs, inherited classes may already be isolated, which shifts the tradeoff. The consistent principle is: prefer the smallest contract that solves the problem, and let the type system enforce what inheritance cannot—that unrelated types can share a calling convention without sharing a family tree.