I have used typedef NS_ENUM
to reorganise data constants in old code. Using an approach found here every typedef
is declared in a single .h
Defining different enums in one .h
.. like just add it one file.
typedef NS_ENUM(NSInteger, MARGIN)
{
MARGIN_Top = 10,
MARGIN_Side = 10,
MARGIN_PanelBaseLine = 1
};
typedef NS_ENUM(long, ENUM_2)
{
ENUM_2_1 = 10,
ENUM_2_2 = 20,
ENUM_2_3 = 30,
};
typedef NS_ENUM(long, ENUM_3)
{
ENUM_3_1 = 10,
ENUM_3_2 = 20,
ENUM_3_3 = 30,
};
// And so on as many as you want
And your second question, Enums can only be of the integral data types like, int
, long
, long long
, unsigned int
, short
etc... You can't use any Non-Integral types like float
or double
or not even any objective c types.
You can do enum mapping for float values like this https://stackoverflow.com/a/8867169/1825618