Objective-C Functions

No overview available.

Topics

Functions

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

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

func class_conformsToProtocol(AnyClass?, Protocol?) -> Bool

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

func class_getClassMethod(AnyClass?, Selector) -> Method?

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

func class_getClassVariable(AnyClass?, UnsafePointer<Int8>) -> Ivar?

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

func class_getImageName(AnyClass?) -> UnsafePointer<Int8>?

Returns the name of the dynamic library a class originated from.

func class_getInstanceMethod(AnyClass?, Selector) -> Method?

Returns a specified instance method for a given class.

func class_getInstanceSize(AnyClass?) -> Int

Returns the size of instances of a class.

func class_getInstanceVariable(AnyClass?, UnsafePointer<Int8>) -> Ivar?

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

func class_getIvarLayout(AnyClass?) -> UnsafePointer<UInt8>?

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

func class_getMethodImplementation(AnyClass?, Selector) -> IMP?

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

func class_getProperty(AnyClass?, UnsafePointer<Int8>) -> objc_property_t?

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

func class_getSuperclass(AnyClass?) -> AnyClass?

Returns the superclass of a class.

func class_getVersion(AnyClass?) -> Int32

Returns the version number of a class definition.

func class_getWeakIvarLayout(AnyClass?) -> UnsafePointer<UInt8>?

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

func class_isMetaClass(AnyClass?) -> Bool

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

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

Replaces the implementation of a method for a given class.

func class_respondsToSelector(AnyClass?, Selector) -> Bool

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

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

Sets the Ivar layout for a given class.

func class_setVersion(AnyClass?, Int32)

Sets the version number of a class definition.

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

Sets the layout for weak Ivars for a given class.

func imp_getBlock(IMP) -> Any?

Returns the block associated with an IMP that was created using imp_implementationWithBlock(_:).

func imp_implementationWithBlock(Any) -> IMP

Creates a pointer to a function that calls the specified block when the method is called.

func imp_removeBlock(IMP) -> Bool

Disassociates a block from an IMP that was created using imp_implementationWithBlock(_:), and releases the copy of the block that was created.

func ivar_getName(Ivar) -> UnsafePointer<Int8>?

Returns the name of an instance variable.

func ivar_getOffset(Ivar) -> Int

Returns the offset of an instance variable.

func ivar_getTypeEncoding(Ivar) -> UnsafePointer<Int8>?

Returns the type string of an instance variable.

func method_copyArgumentType(Method, UInt32) -> UnsafeMutablePointer<Int8>?

Returns a string describing a single parameter type of a method.

func method_copyReturnType(Method) -> UnsafeMutablePointer<Int8>

Returns a string describing a method's return type.

func method_exchangeImplementations(Method, Method)

Exchanges the implementations of two methods.

func method_getArgumentType(Method, UInt32, UnsafeMutablePointer<Int8>?, Int)

Returns by reference a string describing a single parameter type of a method.

func method_getDescription(Method) -> UnsafeMutablePointer<objc_method_description>

Returns a method description structure for a specified method.

func method_getImplementation(Method) -> IMP

Returns the implementation of a method.

func method_getName(Method) -> Selector

Returns the name of a method.

func method_getNumberOfArguments(Method) -> UInt32

Returns the number of arguments accepted by a method.

func method_getReturnType(Method, UnsafeMutablePointer<Int8>, Int)

Returns by reference a string describing a method's return type.

func method_getTypeEncoding(Method) -> UnsafePointer<Int8>?

Returns a string describing a method's parameter and return types.

func method_setImplementation(Method, IMP) -> IMP

Sets the implementation of a method.

func objc_copyClassList(UnsafeMutablePointer<UInt32>?) -> AutoreleasingUnsafeMutablePointer<AnyClass>?

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

func objc_copyImageNames(UnsafeMutablePointer<UInt32>?) -> UnsafeMutablePointer<UnsafePointer<Int8>>

Returns the names of all the loaded Objective-C frameworks and dynamic libraries.

func objc_disposeClassPair(AnyClass)

Destroys a class and its associated metaclass.

func objc_enumerationMutation(Any)

Inserted by the compiler when a mutation is detected during a foreach iteration.

func objc_getAssociatedObject(Any, UnsafeRawPointer) -> Any?

Returns the value associated with a given object for a given key.

func objc_getClass(UnsafePointer<Int8>) -> Any!

Returns the class definition of a specified class.

func objc_getMetaClass(UnsafePointer<Int8>) -> Any!

Returns the metaclass definition of a specified class.

func objc_getRequiredClass(UnsafePointer<Int8>) -> AnyClass

Returns the class definition of a specified class.

func objc_loadWeak(AutoreleasingUnsafeMutablePointer<AnyObject?>) -> Any?

Loads the object referenced by a weak pointer and returns it.

func objc_lookUpClass(UnsafePointer<Int8>) -> AnyClass?

Returns the class definition of a specified class.

func objc_registerClassPair(AnyClass)

Registers a class that was allocated using objc_allocateClassPair(_:_:_:).

func objc_registerProtocol(Protocol)

Registers a newly created protocol with the Objective-C runtime.

func objc_removeAssociatedObjects(Any)

Removes all associations for a given object.

func objc_setAssociatedObject(Any, UnsafeRawPointer, Any?, objc_AssociationPolicy)

Sets an associated value for a given object using a given key and association policy.

func object_getClass(Any?) -> AnyClass?

Returns the class of an object.

func object_getClassName(Any?) -> UnsafePointer<Int8>

Returns the class name of a given object.

func object_getIvar(Any?, Ivar) -> Any?

Reads the value of an instance variable in an object.

func object_setIvar(Any?, Ivar, Any?)

Sets the value of an instance variable in an object.

func property_copyAttributeValue(objc_property_t, UnsafePointer<Int8>) -> UnsafeMutablePointer<Int8>?

Returns the value of a property attribute given the attribute name.

func protocol_addProtocol(Protocol, Protocol)

Adds a registered protocol to another protocol that is under construction.

func protocol_conformsToProtocol(Protocol?, Protocol?) -> Bool

Returns a Boolean value that indicates whether one protocol conforms to another protocol.

func protocol_copyMethodDescriptionList(Protocol, Bool, Bool, UnsafeMutablePointer<UInt32>?) -> UnsafeMutablePointer<objc_method_description>?

Returns an array of method descriptions of methods meeting a given specification for a given protocol.

func protocol_getMethodDescription(Protocol, Selector, Bool, Bool) -> objc_method_description

Returns a method description structure for a specified method of a given protocol.

func protocol_isEqual(Protocol?, Protocol?) -> Bool

Returns a Boolean value that indicates whether two protocols are equal.

func sel_getName(Selector) -> UnsafePointer<Int8>

Returns the name of the method specified by a given selector.

func sel_getUid(UnsafePointer<Int8>) -> Selector

Registers a method name with the Objective-C runtime system.

func sel_isEqual(Selector, Selector) -> Bool

Returns a Boolean value that indicates whether two selectors are equal.

func sel_registerName(UnsafePointer<Int8>) -> Selector

Registers a method with the Objective-C runtime system, maps the method name to a selector, and returns the selector value.

func class_createInstance(AnyClass?, Int) -> Any?

Creates an instance of a class, allocating memory for the class in the default malloc memory zone.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software