---
title: "encodePortObject:"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsportcoder/encodeportobject:"
---

# encodePortObject:

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

## Declaration

```occ
- (void) encodePortObject:(NSPort *) aport;
```

## Parameters

- `aport`: The port to encode.

## Discussion

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 encode(with:) 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 encode(with:) message. See Subclassing NSCoder for more information.

## See Also

### Encoding NSPort Objects

- [decodePortObject](foundation/nsportcoder/decodeportobject.md)
