Skip to content

Instantly share code, notes, and snippets.

@yourtion
Created December 23, 2015 04:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yourtion/66d7b49c896d1611bd28 to your computer and use it in GitHub Desktop.
Save yourtion/66d7b49c896d1611bd28 to your computer and use it in GitHub Desktop.
convert NS_ENUM to NSString
typedef NS_ENUM(NSInteger, JHAlcoholCategory) {
JHAlcoholCategoryWhiteSpirit = 1,
JHAlcoholCategoryChampagne = 11,
JHAlcoholCategoryWine = 12,
JHAlcoholCategoryLiquer = 16,
JHAlcoholCategoryBeer = 17,
JHAlcoholCategoryWineset = 19,
JHAlcoholCategoryGift = 18,
JHAlcoholCategorySet = 20,
JHAlcoholCategoryOneKey = 21,
JHAlcoholCategoryNation = 22
};
NSString * const JHAlcoholCategoryDescription[] = {
[JHAlcoholCategoryWhiteSpirit] = @"Spirit",
[JHAlcoholCategoryChampagne] = @"Champagne",
[JHAlcoholCategoryWine] = @"Wine",
[JHAlcoholCategoryLiquer] = @"Foreignwine",
[JHAlcoholCategoryBeer] = @"Beer",
[JHAlcoholCategoryWineset] = @"Wineset",
[JHAlcoholCategoryGift] = @"Gift"
};
+(NSString *)getAlcoholString:(JHAlcoholCategory)cid {
return JHAlcoholCategoryDescription[cid];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment