Returns the class description for a given class.
SDK
- macOS 10.0+
Framework
- Foundation
Declaration
init?(for aClass: Any Class)
Parameters
aClass
The class for which to return a class description. See note below for important details.
Return Value
The class description for a
, or nil
if a class description cannot be found.
Discussion
If a class description for a
is not found, the method posts an NSClassDescriptionNeededForClassNotification on behalf of a
, 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 class
instead.
Note
In macOS 10.6 and later, this method (and as a result class
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 NSScript
instead.