Explicitly typed enums makes for better type checking and improved code completion.

With the 10.8 SDKs you get warned if you assign between different types of enums. Traditional C enums are implicitly int.
Covered in WWDC 2013 Session 404 – Advances in Objective-C and previsouly covered in depth during WWDC 2012 Talk 405 – Modern Objective-C.

Enums had been traditionally compiled like so:

enum { ABC, JKL, XYZ };
typedef NSUInteger MyEnum;

The new enum is:

enum MyEnum : NSUInteger { ABC, JKL, XYZ };
typedef MyEnum MyEnum;

There are some convenience macros that make it easier to declare enums, either simple values or bit mask options. To define an enum of numeric values you use following macro:

typedef NS_ENUM(NSUInteger, MyEnum) { ABC, JKL, XYZ };

And to define a bit mask enum with options you use:

typedef NS_OPTIONS(NSUInteger, MyOptions)
  kFaster = (1 << 3),
  kBetter = (1 << 4),
  kAwsome = (1 << 5)

This improves code completion and type checking.

Tags: , , , , ,