<!--
{
  "availability" : [
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.13.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSPortCoder",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPortCoder"
  },
  "title" : "NSPortCoder"
}
-->

# NSPortCoder

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

```
@interface NSPortCoder : NSCoder
```

## Overview

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

## Topics

### Creating an NSPortCoder Object

[`portCoderWithReceivePort:sendPort:components:`](/documentation/Foundation/NSPortCoder/portCoderWithReceivePort:sendPort:components:)

Creates and returns a new `NSPortCoder` object.

[`initWithReceivePort:sendPort:components:`](/documentation/Foundation/NSPortCoder/initWithReceivePort:sendPort:components:)

Initializes and returns an `NSPortCoder` object.

### Getting the Connection

[`connection`](/documentation/Foundation/NSPortCoder/connection)

Returns the `NSConnection` object that uses the receiver.

### Encoding NSPort Objects

[`encodePortObject:`](/documentation/Foundation/NSPortCoder/encodePortObject:)

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

[`decodePortObject`](/documentation/Foundation/NSPortCoder/decodePortObject)

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

### Checking for Encoding

[`isBycopy`](/documentation/Foundation/NSPortCoder/isBycopy)

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

[`isByref`](/documentation/Foundation/NSPortCoder/isByref)

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

### Dispatching

[`dispatch`](/documentation/Foundation/NSPortCoder/dispatch)

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



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)