---
title: "init(for:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsclassdescription/init(for:)"
---

# init(for:)

Returns the class description for a given class.

## Declaration

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

## Parameters

- `aClass`: The class for which to return a class description. See note below for important details.

## Return Value

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

## Discussion

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 classDescription instead. note: In macOS 10.6 and later, this method (and as a result 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 init(for:) method of NSScriptClassDescription instead.

## See Also

### Related Documentation

- [Cocoa Scripting Guide](apple-archive/documentation/Cocoa/Conceptual/ScriptableCocoaApplications/SApps_intro/SAppsIntro.html.md)
- [Key-Value Coding Programming Guide](apple-archive/documentation/Cocoa/Conceptual/KeyValueCoding.md)

### Working with class descriptions

- [invalidateClassDescriptionCache()](foundation/nsclassdescription/invalidateclassdescriptioncache().md)
- [register(_:for:)](foundation/nsclassdescription/register(_:for:).md)
