<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSClassDescription",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSClassDescription"
  },
  "title" : "NSClassDescription"
}
-->

# NSClassDescription

An abstract class that provides the interface for querying the relationships and properties of a class.

```
class NSClassDescription
```

## Overview

Concrete subclasses of `NSClassDescription` provide the available attributes of objects of a particular class and the relationships between that class and other classes. Defining these relationships between classes allows for more intelligent and flexible manipulation of objects with key-value coding.

It is important to note that there are no class descriptions by default. To use `NSClassDescription` objects in your code you have to implement them for your model classes. For all concrete subclasses, you must provide implementations for all instance methods of `NSClassDescription`. (`NSClassDescription` provides only the implementation for the class methods that maintain the cache of registered class descriptions.) Once created, you must register a class description with the `NSClassDescription` method [`register(_:for:)`](/documentation/Foundation/NSClassDescription/register(_:for:)).

You can use the `NSString` objects in the arrays returned by methods such as [`attributeKeys`](/documentation/Foundation/NSClassDescription/attributeKeys) and [`toManyRelationshipKeys`](/documentation/Foundation/NSClassDescription/toManyRelationshipKeys)  to access—using key-value coding—the properties of an instance of the class to which a class description object corresponds. For more about attributes and relationships, see Cocoa Fundamentals Guide. For more about key-value coding, see [Key-Value Coding Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/index.html#//apple_ref/doc/uid/10000107i).

[`NSScriptClassDescription`](/documentation/Foundation/NSScriptClassDescription), which is used to map the relationships between scriptable classes, is the only concrete subclass of `NSClassDescription` provided as part of the Cocoa framework.

## Topics

### Working with class descriptions

[`+  classDescriptionForClass:`](/documentation/Foundation/NSClassDescription/init(for:))

Returns the class description for a given class.

[`+  invalidateClassDescriptionCache`](/documentation/Foundation/NSClassDescription/invalidateClassDescriptionCache())

Removes all `NSClassDescription` objects from the cache.

[`+  registerClassDescription:forClass:`](/documentation/Foundation/NSClassDescription/register(_:for:))

Registers an `NSClassDescription` object for a given class in the `NSClassDescription` cache.

### Attribute keys

[`attributeKeys`](/documentation/Foundation/NSClassDescription/attributeKeys)

Overridden by subclasses to return the names of attributes of instances of the described class.

### Relationship keys

[`-  inverseForRelationshipKey:`](/documentation/Foundation/NSClassDescription/inverse(forRelationshipKey:))

Overridden by subclasses to return the name of the inverse relationship from a relationship specified by a given key.

[`toManyRelationshipKeys`](/documentation/Foundation/NSClassDescription/toManyRelationshipKeys)

Overridden by subclasses to return the keys for the to-many relationship properties of instances of the described class.

[`toOneRelationshipKeys`](/documentation/Foundation/NSClassDescription/toOneRelationshipKeys)

Overridden by subclasses to return the keys for the to-one relationship properties of instances of the described class.

### Notifications

[`NSClassDescriptionNeededForClassNotification`](/documentation/Foundation/NSNotification/Name-swift.struct/NSClassDescriptionNeededForClass)

Posted by [`init(for:)`](/documentation/Foundation/NSClassDescription/init(for:)) when a class description cannot be found for a class.

## Relationships

### Conforms To

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`Equatable`](/documentation/Swift/Equatable)

[`Hashable`](/documentation/Swift/Hashable)

[`CVarArg`](/documentation/Swift/CVarArg)

### Inherited By

[`NSScriptClassDescription`](/documentation/Foundation/NSScriptClassDescription)

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

---

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)