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

# connectionWithReceivePort:sendPort:

Returns an `NSConnection` object that communicates using given send and receive ports.

```
+ (instancetype) connectionWithReceivePort:(NSPort *) receivePort sendPort:(NSPort *) sendPort;
```

## Parameters

`receivePort`

A receive port.

`sendPort`

A send port.

## Return Value

An `NSConnection` object that communicates using `receivePort` and `sendPort`.

## Discussion

See [`initWithReceivePort:sendPort:`](/documentation/Foundation/NSConnection/initWithReceivePort:sendPort:) for more information.

## See Also

[`+ (NSConnection *) defaultConnection;`](/documentation/Foundation/NSConnection/defaultConnection)

Returns the default `NSConnection` object for the current thread.



---

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)