美文网首页iOS开发
iOS开发中,枚举类型的一种写法

iOS开发中,枚举类型的一种写法

作者: 左方 | 来源:发表于2018-07-13 11:03 被阅读0次
typedef NS_ENUM(NSInteger, XXXType) {
    A = 1<<0,        
    B = 1<<1,        
    C = 1<<2,       
    D = 1<<3,    
    E = 1<<4    
};
@property (nonatomic)NSInteger XXX;//属性



//设置属性
- (void)setXXX:(XXXType)type
{
    if (![self checXXX:type]) {
        self.XXX |= type;
    }
}
//清除某种属性
- (void)clearXXX:(XXXType)type
{
    self.XXX &= ~type;
}
//检查是否有某种属性
- (BOOL)checkXXX:(XXXType)type
{
    return (self.XXX & type);
}

相关文章

网友评论

    本文标题:iOS开发中,枚举类型的一种写法

    本文链接:https://www.haomeiwen.com/subject/tpljpftx.html