Skip to content

Instantly share code, notes, and snippets.

@yycking
Created December 1, 2016 08:35
Show Gist options
  • Save yycking/0fe3bbdeca63368254c06ecc9f133f44 to your computer and use it in GitHub Desktop.
Save yycking/0fe3bbdeca63368254c06ecc9f133f44 to your computer and use it in GitHub Desktop.
NS_ENUM 支援字串
#define LIST_OF_ServerAPI \
/*會員*/ \
api(登入, member/login) \
api(FB登入, member/fbLogin)
typedef NS_ENUM(NSInteger, ServerAPI) {
#define api(key, name) key,
LIST_OF_ServerAPI
#undef api
};
- (void)call {
NSString *apiKey;
NSString *apiName;
switch (api) {
#define api(key, name) \
case key: \
apiKey = @#key; \
apiName = @#name; \
break;
LIST_OF_ServerAPI
#undef api
default:
NSAssert1(false, @"%@:ServerAPI未實作", NSStringFromSelector(_cmd));
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment