枚举enum

来源:互联网 发布:sql 遍历select结果 编辑:程序博客网 时间:2024/06/06 12:58

例如UITableViewCellStyle,如下:

typedef enum {    UITableViewCellStyleDefault,    UITableViewCellStyleValue1,    UITableViewCellStyleValue2,    UITableViewCellStyleSubtitle} UITableViewCellStyle;

也可以如下定义:

typedef enum {    UITableViewCellStyleDefault,    UITableViewCellStyleValue1,    UITableViewCellStyleValue2,    UITableViewCellStyleSubtitle};typedef NSInteger UITableViewCellStyle;

新式的枚举定义如下:

typedef NS_ENUM(NSInteger, UITableViewCellStyle) {    UITableViewCellStyleDefault,    UITableViewCellStyleValue1,    UITableViewCellStyleValue2,    UITableViewCellStyleSubtitle};

NS_ENUM的参数含义:

  • 第一个参数:存储的类型
  • 第二个参数:类型的名称


0 0
原创粉丝点击