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

# init(for:)

Returns the class description for a given class.

```
init?(for aClass: AnyClass)
```

## Parameters

`aClass`

The class for which to return a class description. See note below for important details.

## Return Value

The class description for `aClass`, or `nil` if a class description cannot be found.

## Discussion

If a class description for `aClass` is not found, the method posts an NSClassDescriptionNeededForClassNotification on behalf of `aClass`, allowing an observer to register a class description. The method then checks for a class description again. Returns `nil` if a class description is still not found.

If you have an instance of the receiver’s class, you can use the `NSObject` instance method <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/classDescription> instead.

> Note:
> In macOS 10.6 and later, this method (and as a result <doc://com.apple.documentation/documentation/ObjectiveC/NSObject-swift.class/classDescription> methods of any object) will return `nil` when the sdef contains no `<class>` element for the Cocoa class, but there is a `<class>` element defined for a superclass.
> 
> This is incorrect, as object instances should never be required to be exactly a given class, any class should be allowed to be a subclass of the required class and receive the correct `<class>` value.
> 
> This situation can have a serious impact on Cocoa Scripting, and there is no plan on changing this behavior.
> 
> Instead of using this method, you should use the ``doc://com.apple.foundation/documentation/Foundation/NSScriptClassDescription/init(for:)`` method of ``doc://com.apple.foundation/documentation/Foundation/NSScriptClassDescription`` instead.

## See Also

  [Cocoa Scripting Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html#//apple_ref/doc/uid/TP40002164)

  [Key-Value Coding Programming Guide](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/KeyValueCoding/index.html#//apple_ref/doc/uid/10000107i)



---

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)