美文网首页
按位与或取反(|&~)在项目中的运用

按位与或取反(|&~)在项目中的运用

作者: MisYing | 来源:发表于2017-11-22 15:37 被阅读0次
    • (KKUserInfoShowMask)getUserInfoShowMaskWithIndexpath:(NSIndexPath *)indexPath andSwitchOn:(BOOL)isOn {
      NSString *title = self.sectionDatas[indexPath.section][indexPath.row];
      KKUserInfoShowMask mask;
      if ([title isEqualToString:KKLocalized(@"kPhone")]) {
      mask = KKUserInfoShowMaskMobile;
      } else if ([title isEqualToString:KKLocalized(@"kTel")]) {
      mask = KKUserInfoShowMaskTel;
      }else if ([title isEqualToString:KKLocalized(@"kPosition")]) {
      mask = KKUserInfoShowMaskPost;
      } else if ([title isEqualToString:KKLocalized(@"kEMail")]) {
      mask = KKUserInfoShowMaskEmail;
      } else if ([title isEqualToString:KKLocalized(@"kAddress")]) {
      mask = KKUserInfoShowMaskAddr;
      } else if ([title isEqualToString:KKLocalized(@"kJobNumber")]) {
      mask = KKUserInfoShowMaskStaffId;
      } else {
      mask = KKUserInfoShowMaskNone;
      }
      //当开启该位时 按位或
      //当关闭该位时,先按位取反,再按位与
      if (isOn) {
      return (self.userInfo.showMask | mask);
      } else {
      return self.userInfo.showMask & (~mask);
      }
      }

    相关文章

      网友评论

          本文标题:按位与或取反(|&~)在项目中的运用

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