Objective-C Invocation Forwarding

Last time I wrote about the complete messaging flow of Objective-C runtime. This time I will focus on one part of that flow to explain it more thoroughly: Invocation Forwarding, aka Slow Message Forwarding.

Actually I don't have much to say because Mike Ash already did such a good job of explaining the details. They are so good that I've already read them twice.

However, each time I found myself easily lost in the details and had difficulties of visualizing the big picture. So I decided to draw the big picture:

  • Functions in top tier are implemented in ObjC code.
  • Functions(purple) in lower tiers are implemented assembly code.
  • Functions and methods in red are key runtime APIs.
  • At the center is the RawArguments struct. It connects assembly and ObjC worlds, passes original method arguments to the delegate implementation, and collects return values back.

I find the result really helpful in understanding the whole thing and hope you enjoy it too.