Function 関数

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>?) -> Bool

Return Value 戻り値

true if the instance variable was added successfully, otherwise false (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 クラスを扱う