二进制枚举

来源:互联网 发布:mysql not in用法 编辑:程序博客网 时间:2024/06/05 02:19
//二进制枚举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 00110000 0001---------0000 0001*/if (direction & EOCPermittedDirectionUp){    //有设置  EOCPermittedDirectionUp}

在枚举的 EOCPermittedDirection 中 如果第 i 个二进制位为 1 表示取了第 i 个数

原创粉丝点击