Skip to content

onekyle/EnumStringConvert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

EnumStringConvert

Generator both Enum and NSString in Objective-C.

  1. Copy the header file to your project

  2. Import the header file

#import "enum_generator.h"
  1. Define your custom Enum
#define WorkStatus(XX) \
XX(WorkStatusUnKnown,) \
XX(WorkStatusWorking,) \
XX(WorkStatusSleeping,=50)

DECLARE_ENUM(WorkStatus, WorkStatus)
  1. enjoy it😆
WorkStatus testWorkStatus = WorkStatusUnKnown;

NSLog(@"workstatus is: %@", stringFromWorkStatus(testWorkStatus));

if (testWorkStatus == WorkStatusFromString(@"WorkStatusUnKnown")) {
    NSLog(@"确认在摸鱼");
}

如果你在天朝

利用宏定义实现枚举转字符串

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published