(obj, varname, weak=False)
Get the value of obj's ivar named varname.

    The returned object is a :mod:`ctypes` data object.

    For non-object types (everything except :class:`objc_id` and subclasses), the returned data object is backed by the
    ivar's actual memory. This means that the data object is only usable as long as the "owner" object is alive, and
    writes to it will directly change the ivar's value.

    For object types, the returned data object is independent of the ivar's memory. This is because object ivars may
    be weak, and thus cannot always be accessed directly by their address.
Get the value of obj's ivar named varname.
Get the value of obj s ivar named varname .
def get_ivar(obj, varname, weak=False):
    """Get the value of obj's ivar named varname.

    The returned object is a :mod:`ctypes` data object.

    For non-object types (everything except :class:`objc_id` and subclasses), the returned data object is backed by the
    ivar's actual memory. This means that the data object is only usable as long as the "owner" object is alive, and
    writes to it will directly change the ivar's value.

    For object types, the returned data object is independent of the ivar's memory. This is because object ivars may
    be weak, and thus cannot always be accessed directly by their address.
    """

    try:
        obj = obj._as_parameter_
    except AttributeError:
        pass

    ivar = libobjc.class_getInstanceVariable(libobjc.object_getClass(obj), ensure_bytes(varname))
    vartype = ctype_for_encoding(libobjc.ivar_getTypeEncoding(ivar))

    if weak:
        value = libobjc.objc_loadWeakRetained(obj.value + libobjc.ivar_getOffset(ivar))
        return libobjc.objc_autoreleaseReturnValue(value)
    elif issubclass(vartype, objc_id):
        return cast(libobjc.object_getIvar(obj, ivar), vartype)
    else:
        return vartype.from_address(obj.value + libobjc.ivar_getOffset(ivar))
def get_ivar ( obj , varname , weak = False ) : try : obj = obj . _as_parameter_ except AttributeError : pass ivar = libobjc . class_getInstanceVariable ( libobjc . object_getClass ( obj ) , ensure_bytes ( varname ) ) vartype = ctype_for_encoding ( libobjc . ivar_getTypeEncoding ( ivar ) ) if weak : value = libobjc . objc_loadWeakRetained ( obj . value + libobjc . ivar_getOffset ( ivar ) ) return libobjc . objc_autoreleaseReturnValue ( value ) elif issubclass ( vartype , objc_id ) : return cast ( libobjc . object_getIvar ( obj , ivar ) , vartype ) else : return vartype . from_address ( obj . value + libobjc . ivar_getOffset ( ivar ) )