How to get the Ivar of a static field on iOS?

What I’ve tried:

public class TestClass{
    public int a = 555;
    public static int sa = 666;
}

public static class Program
{
    public int Main(int argc, AnsiChar** argv)
    {
        var type = typeof(TestClass);
        var field_a = class_getInstanceVariable(type, new AnsiChar[]{'a','\0'});
        var field_sa = class_getInstanceVariable(object_getClass(type), new AnsiChar[]{'s','a','\0'});

        NSLog("%s, %s\n", ivar_getName(field_a), ivar_getName(field_sa));
        // actual log: a, (null)
        // expected: a, sa
    }
}

I’ve also tried to dump all fields/properties/methods of the class and its meta class, but still can’t find where the “static field” is.

You can’t really. Static vars don’t have an ivar.

So there’s not a reflection way to get/set static vars on iOS?
It’s not an actual requirement. I just want to figure it out.

No they work like globals. Is this somethng you need for something?

No it’s not a requirement. I just need to confirm this limitation of my cross-platform reflection utils. :slight_smile: