objc_direct

https://pspdfkit.com/blog/2020/improving-performance-via-objc-direct
https://nshipster.com/direct/

  • “Unannotated monomorphic dispatch is hard” - what does this mean in practice?
  • Methods annotated with obj-c direct are directly invoked without the indirection of obj-msgsend.
  • No subclassing or @selectors allowed.
  • Performance appears like the main reason to do this, but the gains seem fairly minimal.
  • There’s speculation that the main motivation is Apple locking down private APIs, because objc_direct methods can’t be invoked externally in any way.
  • Requires Xcode 12 but can be compiled down to earlier iOS versions.
  • Swizzling is not off the table but can be more difficult.

Reading

Edit