枚举宏(Adopting Modern Objective-C)

使用NS_ENUM 和 NS_OPTIONS宏定义枚举。Adopting Modern Objective-C

使用NS_ENUM宏定义一组互斥的枚举值:

typedef NS_ENUM(NSInteger, UITableViewCellStyle) {
UITableViewCellStyleDefault,
UITableViewCellStyleValue1,
UITableViewCellStyleValue2,
UITableViewCellStyleSubtitle
};//类型名:UITableViewCellStyle

使用NS_OPTIONS定义一个可以组合的值:

typedef NS_OPTIONS(NSUInteger, UIViewAutoresizing) {
UIViewAutoresizingNone = ,
UIViewAutoresizingFlexibleLeftMargin = << ,
UIViewAutoresizingFlexibleWidth = << ,
UIViewAutoresizingFlexibleRightMargin = << ,
UIViewAutoresizingFlexibleTopMargin = << ,
UIViewAutoresizingFlexibleHeight = << ,
UIViewAutoresizingFlexibleBottomMargin = <<
};
上一篇:System.Diagnostics.Stopwatch


下一篇:Codeforces 1093D Beautiful Graph(二分图染色+计数)