class_addIvar(_:_:_:_:_:)
Adds a new instance variable to a class.
Declaration
func class_addIvar(_ cls: AnyClass?, _ name: UnsafePointer<CChar>, _ size: Int, _ alignment: UInt8, _ types: UnsafePointer<CChar>?) -> BoolReturn Value
YES if the instance variable was added successfully, otherwise NO (for example, the class already contains an instance variable with that name).
Discussion
This function may only be called after objc_allocateClassPair(_:_:_:) and before objc_registerClassPair(_:). Adding an instance variable to an existing class is not supported.
The class must not be a metaclass. Adding an instance variable to a metaclass is not supported.
The instance variable’s minimum alignment in bytes is 1<<align. The minimum alignment of an instance variable depends on the ivar’s type and the machine architecture. For variables of any pointer type, pass log2(sizeof(pointer_type)).
See Also
Working with Classes
class_getName(_:)class_getSuperclass(_:)class_setSuperclass(_:_:)class_isMetaClass(_:)class_getInstanceSize(_:)class_getInstanceVariable(_:_:)class_getClassVariable(_:_:)class_copyIvarList(_:_:)class_getIvarLayout(_:)class_setIvarLayout(_:_:)class_getWeakIvarLayout(_:)class_setWeakIvarLayout(_:_:)class_getProperty(_:_:)class_copyPropertyList(_:_:)class_addMethod(_:_:_:_:)