Search code examples
iphoneobjective-c-runtime

object_getIvar fails to read the value of BOOL iVar


object_getIvar(id object, Ivar ivar) reads the values of iVArs properly but fails on a BOOL type iVar and crashes. I need the values of all iVars of a class.Is there any way to resolve it.


Solution

  • object_getIvar seems to return the actual value (not an id) which is in opposition to what the manual says. If you are using ARC, this will cause an immediate processor fault during attempt to retain the returned value which is not an object.

    object_getInstanceVariable() returns a pointer to the information, but ARC refuses to accept the function.