Skip to content

Instantly share code, notes, and snippets.

@cdzombak
Forked from andrewsardone/gist:3859525
Last active October 11, 2015 12:47
Show Gist options
  • Save cdzombak/3860927 to your computer and use it in GitHub Desktop.
Save cdzombak/3860927 to your computer and use it in GitHub Desktop.
enum types in C/Objective-C
// unpredictable backing type for this enum
typedef enum {
CDZTypePhone,
CDZTypeEmail
} CDZType;
// vs.
enum {
CDZTypePhone,
CDZTypeEmail
};
typedef NSUInteger CDZType;
// vs. a better way via Clang's support for C++11 enumerations
// http://clang.llvm.org/docs/LanguageExtensions.html#objc_fixed_enum
typedef enum : NSUInteger {
CDZTypePhone,
CDZTypeEmail
} CDZType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment