Skip to main content
InterviewHubPRO
Section Overview
Q38

Question 38 of 50

Part 3: Runtime Internals, Swift 6 Safety & Systems Programming (25 - 35)

76%
Swift & Concurrency (50 Qs)•Part 3: Runtime Internals, Swift 6 Safety & Systems Programming (25 - 35)

Method Dispatch in Swift: Static vs Table vs Message Dispatch.

senior LevelswiftRuntime Internals

In Simple Words: How the CPU resolves which function implementation to execute:

  1. Static / Direct Dispatch (Fastest): Resolved at compile time. The CPU jumps directly to memory address. Used for final classes, structs, enums, and protocol extensions.
  2. Table Dispatch (V-Table & Witness Table): Looked up via function pointer arrays at runtime. Used for standard class inheritance (V-Table) and protocol conformance (Witness Table).
  3. Message Dispatch (Most Dynamic / Slowest): Uses Objective-C runtime (objc_msgSend). Supports swizzling and dynamic resolution. Enabled with @objc dynamic.