The NSObject object is the root class in Objecitve-C. It has the following two methods. When the method that calls NSObject and its subclass does not exist, it encapsulates this call into the NSInvocation * type and tries to pass it to forwardInvocation: method. If the object called by the original method loads forwardInvocation: method, forwardInvocation: method will be called.
ForwardingTargetForSelector: the real purpose of this function. From the descriptions on the official website, we still do not fully understand the available scenarios, but the latter method was used for reflection processing, see O-R Mapping for json data sources implemented by iOS ".
ForwardingTargetForSelector:
Returns the object to which an unknown message should first be redirected.
Returns the object to which unrecognized messages shoshould first be directed.
-(Id) forwardingTargetForSelector :( SEL) aSelectorforwardInvocation:
It is overloaded by sub-classes and used to forward messages to other objects.
Overridden by subclasses to forward messages to other objects.
-(Void) forwardInvocation :( NSInvocation *) anInvocation
- (void)forwardInvocation:(NSInvocation *)invocation { SEL orignalSelector = [invocation selector]; if ([friend respondsToSelector:orignalSelector]) { [invocation invokeWithTarget:friend]; } else { [super forwardInvocation:invocation]; }}