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

# defaultConnection

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

```
+ (NSConnection *) defaultConnection;
```

## Return Value

The default `NSConnection` object for the current thread, creating it if necessary.

## Discussion

The default `NSConnection` object uses a single `NSPort` object for both receiving and sending and is useful only for vending an object; use the [`rootObject`](/documentation/Foundation/NSConnection/rootObject-c.property) and [`registerName:`](/documentation/Foundation/NSConnection/registerName:) methods to do this.

### Special Considerations

The singleton method of `NSConnection` has been deprecated. It was difficult to ensure that the shared connection wasn’t being used by other operations on the thread on which the default connection was requested. Using `[NSConnection new]` ensures that you get a unique connection object, preventing such collisions.

## See Also

  [Distributed Objects Programming Topics](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/DistrObjects/DistrObjects.html#//apple_ref/doc/uid/10000102i)



---

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)