1、格式
typedef NS_OPTIONS(NSUInteger, UISwipeGestureRecognizerDirection) {
UISwipeGestureRecognizerDirectionNone = 0,
UISwipeGestureRecognizerDirectionRight = 1 << 0,
UISwipeGestureRecognizerDirectionLeft = 1 << 1,
UISwipeGestureRecognizerDirectionUp = 1 << 2,
UISwipeGestureRecognizerDirectionDown = 1 << 3
};
typedef NS\_ENUM(NSInteger, NSWritingDirection) {
NSWritingDirectionNatural = -1,
NSWritingDirectionLeftToRight = 0,
NSWritingDirectionRightToLeft = 1
};
2、只要枚举值需要用到按位或(2个及以上枚举值可多个存在)就使用NS_OPTIONS,否则使用NS_ENUM。