---
title: "inverse(forRelationshipKey:)"
framework: objectivec
role: symbol
role_heading: Instance Method
path: "objectivec/nsobject-swift.class/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.

## Declaration

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

## Parameters

- `relationshipKey`: The name of the relationship from the receiver’s class to another class.

## Return Value

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

## Discussion

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 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: employee inverseForRelationshipKey:@"department"]; returns the string employees.

## See Also

### Working with Class Descriptions

- [attributeKeys](objectivec/nsobject-swift.class/attributekeys.md)
- [classDescription](objectivec/nsobject-swift.class/classdescription.md)
- [toManyRelationshipKeys](objectivec/nsobject-swift.class/tomanyrelationshipkeys.md)
- [toOneRelationshipKeys](objectivec/nsobject-swift.class/toonerelationshipkeys.md)
