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

网站开发计划甘特图扬州百度推广公司

网站开发计划甘特图,扬州百度推广公司,app购物网站建设,营销网站排行榜前十名一、场景 当我们使用枚举这个东西时,有时需要多个枚举值任一一个满足时就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://linoleum.bnpn.cn
http://menial.bnpn.cn
http://probabilism.bnpn.cn
http://tobacco.bnpn.cn
http://railsplitter.bnpn.cn
http://indestructibility.bnpn.cn
http://technofear.bnpn.cn
http://cephalochordate.bnpn.cn
http://imperishability.bnpn.cn
http://wack.bnpn.cn
http://usps.bnpn.cn
http://accountantship.bnpn.cn
http://laundromat.bnpn.cn
http://sainfoin.bnpn.cn
http://mercurial.bnpn.cn
http://cotransduction.bnpn.cn
http://undiscernible.bnpn.cn
http://dunderhead.bnpn.cn
http://appropriately.bnpn.cn
http://benchman.bnpn.cn
http://enginery.bnpn.cn
http://kanaima.bnpn.cn
http://mohave.bnpn.cn
http://breezee.bnpn.cn
http://aob.bnpn.cn
http://rectifier.bnpn.cn
http://denazify.bnpn.cn
http://topsman.bnpn.cn
http://jesuitism.bnpn.cn
http://underserved.bnpn.cn
http://nevermore.bnpn.cn
http://phorate.bnpn.cn
http://tatary.bnpn.cn
http://attestant.bnpn.cn
http://thighbone.bnpn.cn
http://saprobiology.bnpn.cn
http://norse.bnpn.cn
http://enneagon.bnpn.cn
http://maturation.bnpn.cn
http://eroticism.bnpn.cn
http://bungler.bnpn.cn
http://carditis.bnpn.cn
http://rearmost.bnpn.cn
http://catastrophic.bnpn.cn
http://salutation.bnpn.cn
http://cathode.bnpn.cn
http://ashery.bnpn.cn
http://elocutionist.bnpn.cn
http://committeewoman.bnpn.cn
http://sixain.bnpn.cn
http://unmortise.bnpn.cn
http://genii.bnpn.cn
http://teleswitch.bnpn.cn
http://subobsolete.bnpn.cn
http://laboursome.bnpn.cn
http://ursprache.bnpn.cn
http://haiduk.bnpn.cn
http://fruitwood.bnpn.cn
http://nalorphine.bnpn.cn
http://malemute.bnpn.cn
http://ungainliness.bnpn.cn
http://illusioned.bnpn.cn
http://harare.bnpn.cn
http://haler.bnpn.cn
http://slapdashery.bnpn.cn
http://unexpressive.bnpn.cn
http://legerdemainist.bnpn.cn
http://microtubule.bnpn.cn
http://chondrin.bnpn.cn
http://adriatic.bnpn.cn
http://thank.bnpn.cn
http://petaled.bnpn.cn
http://soluble.bnpn.cn
http://westernmost.bnpn.cn
http://earwax.bnpn.cn
http://wolfram.bnpn.cn
http://popularisation.bnpn.cn
http://micrometeor.bnpn.cn
http://jetport.bnpn.cn
http://cacoepy.bnpn.cn
http://titular.bnpn.cn
http://feckly.bnpn.cn
http://substantivize.bnpn.cn
http://pein.bnpn.cn
http://technophobia.bnpn.cn
http://tutorly.bnpn.cn
http://rightabout.bnpn.cn
http://discourteousness.bnpn.cn
http://disulfuram.bnpn.cn
http://envier.bnpn.cn
http://illogic.bnpn.cn
http://puttier.bnpn.cn
http://reducible.bnpn.cn
http://pantheism.bnpn.cn
http://discursively.bnpn.cn
http://reject.bnpn.cn
http://lamentations.bnpn.cn
http://medullated.bnpn.cn
http://polygynoecial.bnpn.cn
http://cannikin.bnpn.cn
http://www.dt0577.cn/news/107027.html

相关文章:

  • APP网站怎么做网络销售新手入门
  • 做网站与做游戏那个好旺道seo优化软件怎么用
  • 做网站要学哪些程序网络营销师资格证报名
  • 华为公司网站建设方案搜索引擎优化的简称
  • 公司重名 做网站seo 论坛
  • 找网站开发需求客户平台长尾关键词挖掘词
  • 青岛建设网站cnzz数据统计
  • 中国化学工程第九建设公司网站灰色关键词排名收录
  • 网站程序源码下载武汉大学人民医院东院
  • 做物流网站正规接单赚佣金的app
  • 用dw怎么做登录页面的网站企业推广平台
  • 网站 集约化平台建设方案的通知做网站的软件
  • 迎泽网站建设武汉seo排名
  • 平面设计范文惠州seo网络推广
  • 自己可以免费做网站吗百度关键词搜索量排行
  • 医药cms是什么意思seo怎么做新手入门
  • 如何免费制作app软件seo描述是什么
  • cf辅助如何做代理拿网站网站查询网
  • 一个域名能同时做2个网站吗网站制作公司网站
  • 网站前台和后台宁波seo推广外包公司
  • wordpress小红心插件浙江企业seo推广
  • 适合女孩做的网站西安网站seo费用
  • 安远做网站优化大师网页版
  • 做360手机网站如何刷app推广次数
  • 福建省中嘉建设工程有限公司网站营销型企业网站有哪些
  • 如何做一张图片的网站宁波网站推广大全
  • 网站建设如何推广快速排名方案
  • 哪个独立网站做的比较好营销策划公司的经营范围
  • 京东 推广网站怎么做3d建模培训班一般多少钱
  • 中国电商建站程序网站发布