Class

NSProxy

An abstract superclass defining an API for objects that act as stand-ins for other objects or for objects that don’t exist yet.

Declaration

@interface NSProxy

Overview

Typically, a message to a proxy is forwarded to the real object or causes the proxy to load (or transform itself into) the real object. Subclasses of NSProxy can be used to implement transparent distributed messaging (for example, NSDistantObject) or for lazy instantiation of objects that are expensive to create.

NSProxy implements the basic methods required of a root class, including those defined in the NSObject protocol. However, as an abstract class it doesn’t provide an initialization method, and it raises an exception upon receiving any message it doesn’t respond to. A concrete subclass must therefore provide an initialization or creation method and override the forwardInvocation: and methodSignatureForSelector: methods to handle messages that it doesn’t implement itself. A subclass’s implementation of forwardInvocation: should do whatever is needed to process the invocation, such as forwarding the invocation over the network or loading the real object and passing it the invocation. methodSignatureForSelector: is required to provide argument type information for a given message; a subclass’s implementation should be able to determine the argument types for the messages it needs to forward and should construct an NSMethodSignature object accordingly. See the NSDistantObject, NSInvocation, and NSMethodSignature class specifications for more information.

Topics

Creating Instances

alloc

Returns a new instance of the receiving class

allocWithZone:

Returns a new instance of the receiving class

Deallocating Instances

dealloc

Deallocates the memory occupied by the receiver.

Finalizing an Object

finalize

The garbage collector invokes this method on the receiver before disposing of the memory it uses.

Handling Unimplemented Methods

forwardInvocation:

Passes a given invocation to the real object the proxy represents.

methodSignatureForSelector:

Raises NSInvalidArgumentException. Override this method in your concrete subclass to return a proper NSMethodSignature object for the given selector and the class your proxy objects stand in for.

Introspecting a Proxy Class

respondsToSelector:

Returns a Boolean value that indicates whether the receiving class responds to a given selector.

Describing a Proxy Class or Object

class

Returns self (the class object).

description

A string containing the real class name and the id of the receiver as a hexadecimal number.

debugDescription

A string containing the real class name and the id of the receiver as a hexadecimal number.

Relationships

Conforms To