objective-cobjective-c-runtimeivar

How can I call a method on and Ivar


I have some code which gives me an Ivar.

// written some code so now I have the following Ivar
Ivar ivar = i_have_an_ivar;

I can get the type of this Ivar by calling ivar_getTypeEncoding method so I know what type is this Ivar. Now I want to call a method on this Ivar. How can I do that?


Solution

  • object_getIvar (id object, Ivar ivar) is the answer. this will give me the object and then I can call a method on that object.