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

# 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()`](/documentation/Foundation/NSCoder/decodeObject()) to decode any object.

`NSPort` invokes this method in its [`init(coder:)`](/documentation/Foundation/NSCoding/init(coder:)) 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 [`init(coder:)`](/documentation/Foundation/NSCoding/init(coder:)) message. See [Subclassing NSCoder](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Archiving/Articles/subclassing.html#//apple_ref/doc/uid/20000951) for more information.

---

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)