Function

objc_getClass(_:)

Returns the class definition of a specified class.

Declaration

func objc_getClass(_ name: UnsafePointer<Int8>) -> Any!

Parameters

name

The name of the class to look up.

Return Value

The Class object for the named class, or nil if the class is not registered with the Objective-C runtime.

Discussion

objc_getClass is different from objc_lookUpClass(_:) in that if the class is not registered, objc_getClass calls the class handler callback and then checks a second time to see whether the class is registered. objc_lookUpClass(_:) does not call the class handler callback.

Special Considerations

Earlier implementations of this function (prior to OS X v10.0) terminate the program if the class does not exist.

See Also

Obtaining Class Definitions

func objc_copyClassList(UnsafeMutablePointer<UInt32>?)

Creates and returns a list of pointers to all registered class definitions.

func objc_lookUpClass(UnsafePointer<Int8>)

Returns the class definition of a specified class.

func objc_getRequiredClass(UnsafePointer<Int8>)

Returns the class definition of a specified class.

func objc_getMetaClass(UnsafePointer<Int8>)

Returns the metaclass definition of a specified class.