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

# registerName:withNameServer:

Registers a service with the specified port name server.

```
- (BOOL) registerName:(NSString *) name withNameServer:(NSPortNameServer *) server;
```

## Parameters

`name`

The name under which to register the receiver.

`server`

The name server.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the operation was successful, otherwise <doc://com.apple.documentation/documentation/Swift/false> (for example, if another `NSConnection` object on the same host is already registered under `name`).

## Discussion

This method connects the receive port of the receiving `NSConnection` object with the specified service name. If the operation is successful, other `NSConnection` objects can contact the receiver using the [`connectionWithRegisteredName:host:`](/documentation/Foundation/NSConnection/connectionWithRegisteredName:host:) and [`rootProxyForConnectionWithRegisteredName:host:`](/documentation/Foundation/NSConnection/rootProxyForConnectionWithRegisteredName:host:) class methods.

If the receiver was already registered under a name and this method returns <doc://com.apple.documentation/documentation/Swift/false>, the old name remains in effect. If this method is successful, it also unregisters the old name.

To unregister an `NSConnection` object, simply invoke [`registerName:`](/documentation/Foundation/NSConnection/registerName:) and supply `nil` as the connection name.

---

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)