tezvyn:

The dynamic keyword and message dispatch

Source: interviewadvanced

WHAT IT TESTS: dispatch mechanisms and ObjC runtime. OUTLINE: dynamic forces Objective-C message dispatch via objc_msgSend, enabling KVO and swizzling, at the cost of skipping inlining and devirtualization.

WHAT IT TESTS: deep understanding of Swift dispatch and the Objective-C runtime. ANSWER OUTLINE: dynamic instructs the compiler to route a member through Objective-C message dispatch using objc_msgSend rather than static or vtable dispatch, which is what makes Key-Value Observing and method swizzling work. The trade-off is performance: dynamic dispatch defeats inlining, devirtualization, and other optimizations, so hot paths pay a real cost. RED FLAG: equating dynamic with @objc alone or with ordinary class polymorphism.

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

The dynamic keyword and message dispatch · Tezvyn