Class

NSDistantObject

NSDistantObject is a concrete subclass of NSProxy that defines proxies for objects in other applications or threads. When a distant object receives a message, in most cases it forwards the message through its NSConnection object to the real object in another application, supplying the return value to the sender of the message if one is received, and propagating any exception back to the invoker of the method that raised it.

Overview

NSDistantObject adds two useful instance methods to those defined by NSProxy: connectionForProxy returns the NSConnection object that handles the receiver; setProtocolForProxy: establishes the set of methods the real object is known to respond to, saving the network traffic required to determine the argument and return types the first time a particular selector is forwarded to the remote proxy.

There are two kinds of distant object: local proxies and remote proxies. A local proxy is created by an NSConnection object the first time an object is sent to another application. It is used by the connection for bookkeeping purposes and should be considered private. The local proxy is transmitted over the network using the NSCoding protocol to create the remote proxy, which is the object that the other application uses. NSDistantObject defines methods for an NSConnection object to create instances, but they’re intended only for subclasses to override—you should never invoke them directly. Use the rootProxyForConnectionWithRegisteredName:host: method of NSConnection, which sets up all the required state for an object-proxy pair.

Symbols

Creating a Local Proxy

+ proxyWithLocal:connection:

Returns a local proxy for a given object and connection, creating the proxy if necessary.

- initWithLocal:connection:

Initializes an NSDistantObject object as a local proxy for a given object.

Creating a Remote Proxy

+ proxyWithTarget:connection:

Returns a remote proxy for a given object and connection, creating the proxy if necessary.

- initWithTarget:connection:

Initializes a newly allocated NSDistantObject as a remote proxy for remoteObject, which is an id in another thread or another application’s address space.

Getting a Proxy’s NSConnection

- connectionForProxy

Returns the connection used by the receiver.

Setting a Proxy’s Protocol

- setProtocolForProxy:

Sets the methods known to be handled by the receiver to those in a given protocol.

Instance Properties

Instance Methods

Relationships

Inherits From

Conforms To