当前位置: 首页 > news >正文

网站开发计划甘特图yahoo搜索引擎提交入口

网站开发计划甘特图,yahoo搜索引擎提交入口,网站成立查询,网站被墙是谁做的一、场景 当我们使用枚举这个东西时,有时需要多个枚举值任一一个满足时就ture,但是常用的枚举NS_ENUM定义好的枚举只能挨个判断,写一坨就既不美观也不好阅读,如下: typedef NS_ENUM (NSInteger, RPTestType){RPTestT…

一、场景

当我们使用枚举这个东西时,有时需要多个枚举值任一一个满足时就ture,但是常用的枚举NS_ENUM定义好的枚举只能挨个判断,写一坨就既不美观也不好阅读,如下:

typedef NS_ENUM (NSInteger, RPTestType){RPTestTypeUnknown = 0, // unknowRPTestTypeValue0,      // 值0RPTestTypeValue1,      // 值1RPTestTypeValue2,      // 值2RPTestTypeValue3,      // 值3RPTestTypeValue4,      // 值4RPTestTypeValue5,      // 值5
};RPTestType testTeype = RPTestTypeUnknown;
if (testTeype == RPTestTypeValue0 ||testTeype == RPTestTypeValue1 || testTeype == RPTestTypeValue2 || testTeype == RPTestTypeValue3 || testTeype == RPTestTypeValue4 || testTeype == RPTestTypeValue5) {NSLog(@"ture");
}

二、利用NS_OPTIONS优化

1、先了解一个关于位运算符的知识点:位运算符浅析

这里用到(左移 << )和 (按位与 & )和(按位或 | )这仨,先明确是怎么个事;

2、先看下NS_OPTIONS如何来定义枚举
typedef NS_OPTIONS (NSInteger, RPTestType){RPTestTypeUnknown = 1 << 0, // unknowRPTestTypeValue0  = 1 << 1, // 值0RPTestTypeValue1  = 1 << 2, // 值1RPTestTypeValue2  = 1 << 3, // 值2RPTestTypeValue3  = 1 << 4, // 值3RPTestTypeValue4  = 1 << 5, // 值4RPTestTypeValue5  = 1 << 6, // 值5
};

这里使用左移定义枚举值,结合位运算可以这么看:
1 << 0 就是 0001,即2的0次方;
1 << 1 就是 0010,即2的1次方;
1 << 2 就是 0100,即2的2次方;
以此类推~

3、再看这么用的好处

当有多个枚举值都符合时做判断时候,可以直接(或 | )起来,然后(与 & )一下子,就能清晰明了的做判断;

RPTestType testType = RPTestTypeUnknown;
RPTestType judgeType = RPTestTypeValue0 | RPTestTypeValue1 | RPTestTypeValue2 | RPTestTypeValue3 | RPTestTypeValue4 | RPTestTypeValue5;
if (testType & judgeType) {NSLog(@"ture");
}

当然最好使的用处是枚举值传参,如SDImage

[self.testImgView sd_setImageWithURL:[NSURL URLWithString:@"xx"]placeholderImage:niloptions:SDWebImageLowPriority | SDWebImageProgressiveLoad |SDWebImageRefreshCached |SDWebImageContinueInBackground];

options这里可以直接传入多个枚举值,可用于方法内部与或运算进行判断,方便传值;类似的还有UIControlState;

typedef NS_OPTIONS(NSUInteger, UIControlState) {UIControlStateNormal       = 0,UIControlStateHighlighted  = 1 << 0,                  // used when UIControl isHighlighted is setUIControlStateDisabled     = 1 << 1,UIControlStateSelected     = 1 << 2,                  // flag usable by app (see below)UIControlStateFocused API_AVAILABLE(ios(9.0)) = 1 << 3, // Applicable only when the screen supports focusUIControlStateApplication  = 0x00FF0000,              // additional flags available for application useUIControlStateReserved     = 0xFF000000               // flags reserved for internal framework use
};
[testBtn setTitle:@"xx"forState:UIControlStateNormal | UIControlStateHighlighted | UIControlStateSelected];
http://www.dinnco.com/news/29002.html

相关文章:

  • 黑客网站网址大全海外网络推广方案
  • 网站建设需要经过哪几个步骤温州网站优化推广方案
  • 响应式官网设计seo伪原创工具
  • 免费软件视频长沙seo搜索
  • 网站建设 中企动力烟台跨境电商网站
  • 济宁网站建设top长春网站关键词排名
  • 婚纱网站页面设计图片如何进行网站推广
  • 中山网站建设外包站长素材网
  • 苏州免费推广的网站自动app优化下载
  • 网站制作包括数据库吗seo zac
  • 大连做网站的公司有哪些seo怎么优化
  • 网页制作题如何优化搜索引擎的搜索功能
  • 吉安公司做网站抖音推广方式有哪些
  • 微信公众号网站建设怎么做网站链接
  • web 设计网站模板青岛网络优化哪家专业
  • asp.net制作网站开发深圳哪里有网络推广渠避
  • 上海网站搭建公司哪家好怎样注册自己的网站
  • 官网招聘和招聘网站企业网站建设的流程
  • 网上注册公司的章程怎么下载出来seo排名优化软件有
  • 临夏城乡建设局网站杭州网站推广平台
  • 青岛网站设计品牌企业百度网盘app下载安装官方免费版
  • php 做网站电话营销销售系统
  • 舟山 网站制作湖南seo推广
  • 如何提高网站百度权重株洲专业seo优化
  • 做音乐的网站设计seo计费怎么刷关键词的
  • 优质网站建设服务品牌营销推广方案
  • wordpress wdcp 伪静态seo指的是
  • 南京做网站哪家最好河南seo外包
  • 宠物网站素材公司网站策划宣传
  • adobe illustrator做网站刚刚突发1惊天大事