What does an ivar contain?

365 Views Asked by At

in the header file, an ivar structure has three members:-

name, type and offset.

I guess name is for storing the name of the variable.

Offset is for storing distance in bytes from the start of the structure.

Please tell me if I am right about these two ? can anyone explain me What is type for ? Is it the datatype or the scope telling whether it is public ,private or protected.

1

There are 1 best solutions below

3
On BEST ANSWER

It's a C string containing the instance variable's type encoding. See Type Encodings in your local copy of Objective-C Runtime Programming Guide.

You should not access Ivar fields directly, though, because Ivar is an opaque type. It's better to use ivar_getTypeEncoding() for that.