1、格式
typedef NS_OPTIONS(NSUInteger, UISwipeGestureRecognizerDirection) {
UISwipeGestureRecognizerDirectionNone = 0, //值为0
UISwipeGestureRecognizerDirectionRight = 1 << 0, //值为2的0次方
UISwipeGestureRecognizerDirectionLeft = 1 << 1, //值为2的1次方
UISwipeGestureRecognizerDirectionUp = 1 << 2, //值为2的2次方
UISwipeGestureRecognizerDirectionDown = 1 << 3 //值为2的3次方
};
typedef NS\_ENUM(NSInteger, NSWritingDirection) {
NSWritingDirectionNatural = -1, //值为-1
NSWritingDirectionLeftToRight = 0, //值为0
NSWritingDirectionRightToLeft = 1 //值为1
};
2、只要枚举值需要用到按位或(2个及以上枚举值可多个存在)就使用NS_OPTIONS,否则使用NS_ENUM。
NS_OPTIONS与NS_ENUM的区别与格式
最新推荐文章于 2024-06-27 13:58:44 发布