Skip to content

Instantly share code, notes, and snippets.

@paolonl
Forked from ksm/gist:3689409
Created August 10, 2013 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paolonl/6201375 to your computer and use it in GitHub Desktop.
Save paolonl/6201375 to your computer and use it in GitHub Desktop.
/*
Enum with Fixed Underlying Type
New with Xcode 4.4
Via WWDC2012 Session 405 - Modern Objective-C
Results in better code completion and stronger type checking.
Use -Wconversion compiler flag to check for enum type errors.
-Wswitch for checking if switch statement is fully handled for enum.
*/
typedef enum NSNumberFormatterStyle : NSUInteger {
NSNumberFormatterNoStyle,
NSNumberFormatterDecimalStyle,
NSNumberFormatterCurrencyStyle,
NSNumberFormatterPercentStyle,
NSNumberFormatterScientificStyle,
NSNumberFormatterSpellOutStyle
} NSNumberFormatterStyle;
/*
NS_ENUM macro - checks whether fixed underlying type is available,
uses if it is. (What Foundation headers are starting to use).
*/
typedef NS_ENUM(NSUInteger, NSNumberFormatterStyle) {
NSNumberFormatterNoStyle,
NSNumberFormatterDecimalStyle,
NSNumberFormatterCurrencyStyle,
NSNumberFormatterPercentStyle,
NSNumberFormatterScientificStyle,
NSNumberFormatterSpellOutStyle
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment