Contents

NSDistantObject

A proxy for objects in other applications or threads.

Declaration

@interface NSDistantObject : NSProxy

Overview

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.

NSDistantObject is a concrete subclass of NSProxy, adding two useful instance methods of its own: 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.

Topics

Creating a Local Proxy

Creating a Remote Proxy

Getting a Proxy’s NSConnection

Setting a Proxy’s Protocol

Instance Methods

See Also

Legacy