# NSPortCoder class reference

mccallum@gnu.ai.mit.edu
1997,2000 Free Software Foundation, Inc.
Software documentation for the NSPortCoder class
Foundation/NSPortCoder.h
This class is an NSCoder implementation specialized for sending objects over network connections for immediate use (as opposed to the archivers which persist objects for reconstitution after an indefinite term). It is used to help implement the distributed objects framework by the NSConnection class. Even for highly specialized applications, you probably do not need to use this class directly.
portCoderWithReceivePort:
recv
sendPort:
send
components:
comp
Create a new instance for communications over send and recv, and send an initial message through send as specified by comp.
connection
Returns the `NSConnection` using this instance.
decodePortObject
Return port object previously encoded by this instance. Mainly for use by the ports themselves.
dispatch
Processes and acts upon the initial message the receiver was initialized with..
encodePortObject:
aPort
Encodes aPort so it can be sent to the receiving side of the connection. Mainly for use by the ports themselves.
initWithReceivePort:
recv
sendPort:
send
components:
comp
Initialize a new instance for communications over send and recv, and send an initial message through send as specified by comp.
isBycopy
Returns `YES` if receiver is in the process of encoding objects by copying them (rather than substituting a proxy). This method is mainly needed internally and by subclasses.
isByref
Returns `YES` if receiver will substitute a proxy when encoding objects rather than by copying them. This method is mainly needed internally and by subclasses.
Software documentation for the NSObject(NSPortCoder) category
Foundation/NSPortCoder.h
This informal protocol allows an object to control the details of how an object is sent over the wire in distributed objects Port communications.
classForPortCoder
Must return the class that will be created on the remote side of the connection. If the class to be created is not the same as that of the object returned by replacementObjectForPortCoder: then the class must be capable of recognising the object it actually gets in its initWithCoder: method. The default operation is to return NSDistantObject unless the object is being sent bycopy, in which case the objects actual class is returned. To force bycopy operation the object should return its own class.
Override to substitute class when an instance is being serialized by an NSPortCoder . Default implementation returns -classForCoder .
replacementObjectForPortCoder:
aCoder
This message is sent to an object about to be encoded for sending over the wire. The default action is to return an NSDistantObject which is a local proxy for the object unless the object is being sent bycopy, in which case the actual object is returned. To force bycopy, an object should return itself.
Returns the actual object to be encoded for sending over the network on a Distributed Objects connection.
The default implementation returns self if the receiver is being sent bycopy and returns a proxy otherwise.
Subclasses may override this method to change this behavior, eg. to ensure that they are always copied.