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

# connection

Returns the `NSConnection` object that uses the receiver.

```
- (NSConnection *) connection;
```

## Return Value

The `NSConnection` object that uses the receiver. In an object’s [`encode(with:)`](/documentation/Foundation/NSCoding/encode(with:)) method, this is the sending (server) connection. In [`init(coder:)`](/documentation/Foundation/NSCoding/init(coder:)) this is the receiving (client) connection.

---

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)