<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "ObjectiveC",
  "identifier" : "/documentation/ObjectiveC/NSObject-swift.class/inverse(forRelationshipKey:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Objective-C Runtime",
      "ObjectiveC"
    ],
    "preciseIdentifier" : "c:objc(cs)NSObject(im)inverseForRelationshipKey:"
  },
  "title" : "inverse(forRelationshipKey:)"
}
-->

# inverse(forRelationshipKey:)

For a given key that defines the name of the relationship from the receiver’s class to another class, returns the name of the relationship from the other class to the receiver’s class.

```
func inverse(forRelationshipKey relationshipKey: String) -> String?
```

## Parameters

`relationshipKey`

The name of the relationship from the receiver’s class to another class.

## Return Value

The name of the relationship that is the inverse of the receiver’s relationship named `relationshipKey`.

## Discussion

`NSObject`’s implementation of `inverseForRelationshipKey:` simply invokes `[[self classDescription] inverseForRelationshipKey:relationshipKey]`.  To make use of the default implementation, you must therefore implement and register a suitable class description—see <doc://com.apple.documentation/documentation/Foundation/NSClassDescription>.

For example, suppose an Employee class has a relationship named `department` to a Department class, and that Department has a relationship called `employees` to Employee. The statement:

```objc
employee inverseForRelationshipKey:@"department"];
```

returns the string `employees`.

---

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)