NSProxy, nsproxynsobject
The NSProxy class is very important in the distributed object architecture. Because of its special functions, NSProxyCocoaThe frequency of appearance in the program is very low.
NSProxy is an abstract class that defines a set of APIS for objects that behave like other object substitutes or do not exist. Generally, the message sent to the proxy is forwarded to a real object or load (or convert itself into) a real object. The NSProxy base class can be used to transparently forward messages or lazy initialization of costly objects. NSProxy implements the basic methods required for base classes, including the NSObject protocol, but as a virtual base class, it does not provide initialization methods. It will generate an exception when it receives any method that is not defined by itself, so an actual subclass must provide an initialization method or creation method, and reload forwardInvocation: method and methodSignatureForSelector: method to process messages that are not implemented by yourself. ForwardInvocation of a subclass: The implementation should take all measures to handle invocation, such as forwarding network messages, loading a real object, and forwarding invocation to it. MethodSignatureForSelector: To provide parameter type information for a given message, the implementation of the subclass should be able to determine the parameter type of the message to be forwarded and construct the corresponding NSMethodSignature object. For details, see the type descriptions of NSDistantObject, NSInvocation, and NSMethodSignature.