Next Page > Hide TOC

NSPortCoder Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.0 and later.
Companion guide
Declared in
NSPortCoder.h

Overview

NSPortCoder is a concrete subclass of NSCoder used in the distributed objects system to transmit object proxies (and sometimes objects themselves) between NSConnection objects. An NSPortCoder instance is always created and used by an NSConnection object; you should never need to explicitly create or use one directly yourself.

Tasks

Creating an NSPortCoder Object

Getting the Connection

Encoding NSPort Objects

Checking for Encoding

Dispatching

Class Methods

portCoderWithReceivePort:sendPort:components:

Creates and returns a new NSPortCoder object.

+ (id)portCoderWithReceivePort:(NSPort *)rcvPort sendPort:(NSPort *)sndPort components:(NSArray *)comps

Parameters
receiverPort

The receiver port.

sendPort

The send port.

components

An array containing an encoded distributed objects message.

Return Value

A new NSPortCoder object connected to the communication ports receiverPort and sendPort, with an encoded distributed objects message stored in components.

Availability
See Also
Declared In
NSPortCoder.h

Instance Methods

connection

Returns the NSConnection object that uses the receiver.

- (NSConnection *)connection

Return Value

The NSConnection object that uses the receiver. In an object’s encodeWithCoder: method, this is the sending (server) connection. In initWithCoder: this is the receiving (client) connection.

Availability
Declared In
NSPortCoder.h

decodePortObject

Decodes and returns an NSPort object that was previously encoded with any of the general encode...Object: messages.

- (NSPort *)decodePortObject

Return Value

An NSPort object that was previously encoded with any of the general encode...Object: messages.

Discussion

This method is primarily for use by NSPort objects themselves—you can always use decodeObject to decode any object.

NSPort invokes this method in its initWithCoder: method so the appropriate kernel information for the port can be decoded. A subclass of NSPortCoder shouldn’t decode an NSPort by sending it an initWithCoder: message. See Subclassing NSCoder for more information.

Availability
Declared In
NSPortCoder.h

dispatch

Processes and acts upon the distributed object message with which the receiver was initialized.

- (void)dispatch

Availability
See Also
Declared In
NSPortCoder.h

encodePortObject:

Encodes a given port so it can be properly reconstituted in the receiving process or thread.

- (void)encodePortObject:(NSPort *)aPort

Parameters
aPort

The port to encode.

Discussion

This method is primarily for use by NSPort objects themselves—you can always use the general encode...Object: methods to encode any object.

NSPort invokes this method in its encodeWithCoder: method so that the appropriate kernel information for the port can be encoded. A subclass of NSPortCoder should not encode an NSPort by sending it an encodeWithCoder: message. See Subclassing NSCoder for more information.

Availability
Declared In
NSPortCoder.h

initWithReceivePort:sendPort:components:

Initializes and returns an NSPortCoder object.

- (id)initWithReceivePort:(NSPort *)receiverPort sendPort:(NSPort *)sendPort components:(NSArray *)components

Parameters
receiverPort

The receive port.

sendPort

The send port.

components

An array containing an encoded distributed objects message.

Discussion

Initializes a newly allocated NSPortCoder object connected to the communication ports receiverPort and sendPort, with an encoded distributed objects message stored in components.

Availability
See Also
Declared In
NSPortCoder.h

isBycopy

Returns a Boolean value that indicates whether the receiver is encoding an object by copying it.

- (BOOL)isBycopy

Return Value

YES if the receiver is encoding an object by copying it, NO if it expects a proxy.

Discussion

See Distributed Objects Programming Topics for more information.

Availability
See Also
Declared In
NSPortCoder.h

isByref

Returns a Boolean value that indicates whether the receiver is encoding an object by reference.

- (BOOL)isByref

Return Value

YES if the receiver is encoding an object byref, NO if it expects a copy.

Discussion

See Distributed Objects Programming Topics for more information.

Availability
See Also
Declared In
NSPortCoder.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-01-29)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.