object_getIvar(_:_:)
Reads the value of an instance variable in an object.
Declaration
func object_getIvar(_ obj: Any?, _ ivar: Ivar) -> Any?Parameters
- obj:
The object containing the instance variable whose value you want to read.
- ivar:
The Ivar describing the instance variable whose value you want to read.
Return Value
The value of the instance variable specified by ivar, or nil if object is nil.
Discussion
object_getIvar(_:_:) is faster than object_getInstanceVariable if the Ivar for the instance variable is already known.