The new enum in Objective-C

Viewed 12124

In the latest tools, a new kind of enums are now allowed:

typedef enum CarType : NSUInteger {
  FourDoorCarType,
  TwoDoorCarType
} CarType;

My question comes in parts:

  1. Why should I use this instead of the old way?

  2. Why does CarType appear twice? I tried skipping the first CarType and just leaving the first line as "typedef enum : NSUInteger {", and it seems to work fine. What are the drawbacks, if any?

  3. Can some types other than NSUInteger be used?

6 Answers
Related