Created
December 1, 2016 08:35
-
-
Save yycking/0fe3bbdeca63368254c06ecc9f133f44 to your computer and use it in GitHub Desktop.
NS_ENUM 支援字串
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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