Objetive-C列舉位移操作&Swift列舉位移操作
阿新 • • 發佈:2019-01-01
Objective-C 列舉
typedef NS_ENUM(NSInteger,LineDirection){
LineDirectionTop = 1 << 0,
LineDirectionBottom = 1 << 1,
LineDirectionLeft = 1 << 2,
LineDirectionRight = 1 << 3
};
objective-C & 與運算判斷舉例
if (direction & LineDirectionTop) {
}
Swift 列舉
enum LineDirection:UInt8 {
case top = 0b0001
case bottom = 0b0010
case left = 0b0100
case right = 0b1000
}
Swift & 與運算判斷舉例
if (direction.rawValue & LineDirection.top.rawValue) != 0b000 ){
}