iOS message forwarding mechanism (VN's way of escape) --- Transferred from丨n Aquarius Vegetable Bugs

The article is well written. The combination of the iOS message forwarding mechanism and LOL is quite perfect, and the boring things are brought to life. It can be seen that the author is an old LOL driver. Interested friends can click the original address below to take a look.


write picture description here

  • In the first stage, first consult the class to which the message receiver belongs to see if it can dynamically add methods to deal with the current unresponsive selector and dynamic method resolution. If the execution of the first phase of the runtime system ends, the receiver can no longer respond to the message by dynamically adding a method and enter the second phase.
  • In the second stage, see if there are other objects (alternate receivers) that can handle the message. If there is, the runtime system will send the message to that object, and the forwarding process will end; if not, the complete message forwarding mechanism will be started.
  • The third stage is the complete message forwarding mechanism. The runtime system will encapsulate all the details related to the message into the NSInvocation object, and give the receiver one last chance to solve the problem that has not been dealt with.

Original address: https://www.jianshu.com/p/367b2f6b461f

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325609320&siteId=291194637
Recommended