1. 定义枚举

 

 

#import <UIKit/UIKit.h>

typedef enum

{

    //以下是枚举成员

    TestA = 0,

    TestB = 1,

    TestC = 2,

    TestD = 3

    

}TestType;//枚举名称

 

//枚举第二种写法

 

typedef NS_ENUM(NSInteger ,Test)

{

    

    Test1 = 0,

    test2 = 1,

    Test3 = 2,

    Test4 = 3

};

 

@interface ViewController : UIViewController

 

2.定义枚举属性

@property(nonatomic,assign)TestType type;

 

3.使用枚举

- (void)viewDidLoad {

    [super viewDidLoad];

    NSLog(@"%d%d%d%d",TestA,TestB,TestC,TestD);

    if (self.type == 0) {

        NSLog(@"我很好");

    }

}

 

posted on 2018-08-01 16:50  强者VS弱者  阅读(250)  评论(0编辑  收藏  举报