In C# I can write 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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.