枚举
typedef enum
{
ZFDirectTypeLeft,
ZFDirectTypeRight,
ZFDirectTypeUp,
ZFDirectTypeDown,
}ZFDirectType;
typedef NS_ENUM(NSInteger,ZFDirectType2)
{
ZFDirectType2Left,
ZFDirectType2Right,
ZFDirectType2Up,
ZFDirectType2Down,
};
typedef NS_OPTIONS(NSInteger, ZFDirectType3)
{
ZFDirectType3Left = 1 << 0,
ZFDirectType3Right = 1 << 1 ,
ZFDirectType3Up = 1 << 2,
ZFDirectType3Down = 1 << 3,
};
- (void)viewDidLoad
{
[self directCheck:ZFDirectType3Left | ZFDirectType3Up | ZFDirectType3Down | ZFDirectType3Right];
}
- (void)directCheck:(ZFDirectType3)direct
{
if(direct & ZFDirectType3Up)
{
NSLog(@"向上---%zd",direct & ZFDirectType3Up);
}
if(direct & ZFDirectType3Down)
{
NSLog(@"向下---%zd",direct & ZFDirectType3Down);
}
if(direct & ZFDirectType3Left)
{
NSLog(@"向左---%zd",direct & ZFDirectType3Left);
}
if(direct & ZFDirectType3Right)
{
NSLog(@"向右---%zd",direct & ZFDirectType3Right);
}
}