Function

class_copyMethodList(_:_:)

Describes the instance methods implemented by a class.

Declaration

func class_copyMethodList(_ cls: AnyClass?, _ outCount: UnsafeMutablePointer<UInt32>?) -> UnsafeMutablePointer<Method>?

Parameters

cls

The class you want to inspect.

outCount

On return, contains the length of the returned array. If outCount is NULL, the length is not returned.

Return Value

An array of pointers of type Method describing the instance methods implemented by the class—any instance methods implemented by superclasses are not included. The array contains *outCount pointers followed by a NULL terminator. You must free the array with free().

If cls implements no instance methods, or cls is Nil, returns NULL and *outCount is 0.

Discussion

To get the class methods of a class, use class_copyMethodList(object_getClass(cls), &count).

To get the implementations of methods that may be implemented by superclasses, use class_getInstanceMethod(_:_:) or class_getClassMethod(_:_:).

See Also

Working with Classes

func class_getName(AnyClass?)

Returns the name of a class.

func class_getSuperclass(AnyClass?)

Returns the superclass of a class.

func class_setSuperclass(AnyClass, AnyClass)

Sets the superclass of a given class.

Deprecated
func class_isMetaClass(AnyClass?)

Returns a Boolean value that indicates whether a class object is a metaclass.

func class_getInstanceSize(AnyClass?)

Returns the size of instances of a class.

func class_getInstanceVariable(AnyClass?, UnsafePointer<Int8>)

Returns the Ivar for a specified instance variable of a given class.

func class_getClassVariable(AnyClass?, UnsafePointer<Int8>)

Returns the Ivar for a specified class variable of a given class.

func class_copyIvarList(AnyClass?, UnsafeMutablePointer<UInt32>?)

Describes the instance variables declared by a class.

func class_getIvarLayout(AnyClass?)

Returns a description of the Ivar layout for a given class.

func class_setIvarLayout(AnyClass?, UnsafePointer<UInt8>?)

Sets the Ivar layout for a given class.

func class_getWeakIvarLayout(AnyClass?)

Returns a description of the layout of weak Ivars for a given class.

func class_setWeakIvarLayout(AnyClass?, UnsafePointer<UInt8>?)

Sets the layout for weak Ivars for a given class.

func class_getProperty(AnyClass?, UnsafePointer<Int8>)

Returns a property with a given name of a given class.

func class_addMethod(AnyClass?, Selector, IMP, UnsafePointer<Int8>?)

Adds a new method to a class with a given name and implementation.

func class_getInstanceMethod(AnyClass?, Selector)

Returns a specified instance method for a given class.

func class_getClassMethod(AnyClass?, Selector)

Returns a pointer to the data structure describing a given class method for a given class.

func class_replaceMethod(AnyClass?, Selector, IMP, UnsafePointer<Int8>?)

Replaces the implementation of a method for a given class.

func class_getMethodImplementation(AnyClass?, Selector)

Returns the function pointer that would be called if a particular message were sent to an instance of a class.

func class_getMethodImplementation_stret(AnyClass?, Selector)

Returns the function pointer that would be called if a particular message were sent to an instance of a class.

func class_respondsToSelector(AnyClass?, Selector)

Returns a Boolean value that indicates whether instances of a class respond to a particular selector.

func class_conformsToProtocol(AnyClass?, Protocol?)

Returns a Boolean value that indicates whether a class conforms to a given protocol.

func class_getVersion(AnyClass?)

Returns the version number of a class definition.

func class_setVersion(AnyClass?, Int32)

Sets the version number of a class definition.