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

用幽默的语言来形容网站开发百度品牌广告是什么

用幽默的语言来形容网站开发,百度品牌广告是什么,网页软件下载,南宁推广软件一、场景 当我们使用枚举这个东西时,有时需要多个枚举值任一一个满足时就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.yidumall.com/news/34924.html

相关文章:

  • 如何检查网站是否被挂木马16888精品货源入口
  • 福田附近公司做网站建设多少钱怎么做产品推广平台
  • 做游乐设施模型的网站提高工作效率的工具
  • 网站开发答辩ppt聊城网站开发
  • 如何通过网站开发客户微信公众号推广软文案例
  • 宁波江北建设局网站互联网推广方式
  • 网站建设明细报价北京今日重大新闻
  • 淄博营销网站建设公司青岛网站seo服务
  • 网站开发主要包括哪些方面免费网站软件推荐
  • 微网站开发费用培训学校
  • asp网站设计代做昆明网络营销
  • WordPress主题不显示评论临沂做网络优化的公司
  • wordpress 技术交流群店铺seo是什么意思
  • 做网站用windows和 linux企业网站的作用
  • 用php做网站用什么框架福州seo网址优化公司
  • 手机哪里可以做视频网站电商运营推广
  • 在线购物的网站制作官网首页入口百度
  • 外国企业网站模板免费下载广州网络公司
  • 高端建站优化网站关键词排名
  • 龙岗模板网站建设seo含义
  • 用服务器建立网站教程西安seo优化排名
  • 交城有做网站的吗百度搜索指数是怎么计算的
  • 如何做网站标题推广计划方案模板
  • 做网站需要独立ip吗成功的软文营销案例
  • 八宝山做网站的公司台州百度推广优化
  • 佛山附近做网站的公司软件开发交易平台
  • 免费的网站空间软件开发网
  • 网站在线qq客服代码中国网民博客 seo
  • 辽宁住房和建设厅网站首页百度搜索名字排名优化
  • 道滘镇做网站佛山seo培训机构