//二进制枚举
typedef NS_OPTIONS(NSUInteger, EOCPermittedDirection){
EOCPermittedDirectionUp = 1 << 0,//即0000 0001
EOCPermittedDirectionDown = 1 << 1,// 即 0000 0010
EOCPermittedDirectionLeft = 1 << 2, // 即 0000 0100
EOCPermittedDirectionRight = 1 << 3, // 即 0000 1000
}
//二进制枚举使用
EOCPermittedDirection direction = EOCPermittedDirectionUp | EOCPermittedDirectionDown;//// 即 0000 0011
/*
0000 0011
0000 0001
---------
0000 0001
*/
if (direction & EOCPermittedDirectionUp){
//有设置 EOCPermittedDirectionUp
}
在枚举的 EOCPermittedDirection 中 如果第 i 个二进制位为 1 表示取了第 i 个数