Class

NSDistantObject

A proxy for objects in other applications or threads.

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

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

See Also

Legacy

NSMachPortDelegate

An interface for handling incoming Mach messages.

NSConnectionDelegate

An interface for interacting with low-level, interprocess connections.

Deprecated
NSConnection

An object that manages the communication between objects in different threads or between a thread and a process running on a local or remote system.

Deprecated
NSDistantObjectRequest

An object used by the distributed objects system to help handle invocations between different processes.

Deprecated
NSMachBootstrapServer

A port name server that takes and returns Mach port objects.

Deprecated
NSMachPort

A port that can be used as an endpoint for distributed object connections (or raw messaging).

NSMessagePort

A port that can be used as an endpoint for distributed object connections (or raw messaging).

NSMessagePortNameServer

A server takes and returns message ports.

Deprecated
NSPortCoder

A coder used to transmit object proxies (and sometimes objects themselves) between connections.

Deprecated
NSPortDelegate

An interface for handling incoming messages.

NSPortMessage

A low-level, operating system-independent type for inter-application (and inter-thread) messages.

NSPortNameServer

An object-oriented interface to the port registration service used by the distributed objects system.

Deprecated
NSProtocolChecker

An object that restricts the messages that can be sent to another object (referred to as the checker’s delegate).

NSSocketPortNameServer

A port name server that takes and returns socket ports.

Deprecated