Obtains the list of registered class definitions.
- iOS 2.0+
- macOS 10.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
- Objective-C Runtime
An array of
Classvalues. On output, each
Classvalue points to one class definition, up to either
bufferor the total number of registered classes, whichever is less. You can pass
NULLto obtain the total number of registered class definitions without actually retrieving any class definitions.
An integer value. Pass the number of pointers for which you have allocated space in
buffer. On return, this function fills in only this number of elements. If this number is less than the number of registered classes, this function returns an arbitrary subset of the registered classes.
An integer value indicating the total number of registered classes.
The Objective-C runtime library automatically registers all the classes defined in your source code. You can create class definitions at runtime and register them with the
Listing 1 demonstrates how to use this function to retrieve all the class definitions that have been registered with the Objective-C runtime in the current process.
You cannot assume that class objects you get from this function are classes that inherit from
NSObject, so you cannot safely call any methods on such classes without detecting that the method is implemented first.