How to specify the integral type for my enum type like in C#?
In C# I can wr开发者_如何学Pythonite something like this: enum MyEnum : byte { Value1, Value2, Value3 } and the integral type of MyEnum will be byte.
In Objective-C I want the size of MyEnum to be 1 byte. How can I do it?
You can't do it, the underlying type for enums will be chosen for you by the compiler.
If you need specific sizes, use a suitable type (e.g. uint8_t
) for your variables and make sure the values in the enumeration fit in that types value range.
精彩评论