Change enum values at runtime?
问题 Is there a way to assign values to enums during runtime in objective c? I have several enums and want each of the enum to have certain value. The values could be read from a xml file. Is there a way to do this? 回答1: Unfortunatley, @Binyamin is correct, you cannot do this with an enum. For this reason, I usually do the following in my projects: // in .h typedef int MyEnum; struct { MyEnum value1; MyEnum value2; MyEnum value3; } MyEnumValues; // in .m __attribute__((constructor)) static void