Rapid message forwarding process
Message forwarding, as the name implies, forwards messages to other recipients, that is, other objects
forwardingTargetForSelector
- If we don’t do that either
resolveInstanceMethod
After viewing the log, you can see the call laterforwardingTargetForSelector
- Take a look at the official documentation
If an object implements (or inherits) this method, and returns a non-nil (and non-self) result, that returned object is used as the new receiver object and the message dispatch resumes to that new object. (Obviously if you return self from this method, the code would just fall into an infinite loop.) If you implement this method in a non-root class, Invoking Super’s if your class has nothing to return for the given selector then you should return the result of invoking Super’s implementation. This method gives an object a chance to redirect an unknown message sent to it before the much more expensive forwardInvocation: machinery takes over. This is useful when you simply want to redirect messages to another object and can be an order of magnitude faster than regular forwarding. It is not useful where the goal of the forwarding is to capture the NSInvocation, or manipulate the arguments or return value during the forwarding.
- It’s like redirecting
- This can be called by returning a new object
method
. - It’s consuming more
forwardInvocation:
Methods before
WLWPerson
Do not implementlook
Method, implementforwardingTargetForSelector
The specifiedWLWTeacher
calllook
The message is forwarded slowly
- If not implemented also
forwardingTargetForSelector
Will gomethodSigntureForSeletor
- The official documentation
- through
methodSignatrueForSelector
To get the signature of the message to create oneNSInvocation
Object is used to forward messages forwardingInvocation
Method to forward the message, of course, you can do no processing- The official demo
- You can also call
doesNotRecognizeSelector
To prevent message forwarding
The source code parsing
- The print stack found that the message source came from
CFFoundation
The source code - But find the source code does not find the corresponding code, may be no open source
- If you want to continue exploring, you can go through
image list
Find the correspondingCoreFoundtion
Executable files, and then explore through disassembly - using
Hopper
Tools will be foundCoreFoundtion
Drag the executable file in