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.
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, becauseIvar
is an opaque type. It's better to useivar_getTypeEncoding()
for that.