Objective C - when should "typedef" precede "enum", and when should an enum be named?
Posted
by Scott Pendleton
on Stack Overflow
See other posts from Stack Overflow
or by Scott Pendleton
Published on 2010-04-02T21:24:55Z
Indexed on
2010/04/02
21:33 UTC
Read the original article
Hit count: 558
In sample code, I have seen this:
typedef enum Ename { Bob, Mary, John} EmployeeName;
and this:
typedef enum {Bob, Mary, John} EmployeeName;
and this:
typedef enum {Bob, Mary, John};
but what compiled successfully for me was this:
enum {Bob, Mary, John};
I put that line in a .h file above the @interface line, and then when I #import that .h file into a different class's .m file, methods there can see the enum.
So, when are the other variants needed?
If I could name the enum something like EmployeeNames, and then, when I type "EmployeeNames" followed by a ".", it would be nice if a list pops up showing what the enum choices are.
© Stack Overflow or respective owner