• Xcode warning: code will never be executed.


    在xcode编译的时候,提示了code will never be executed这个警告。百度了一下,大体的意思是,该代码永远不会执行的意思。

    比如:

    - (void)setMyStyle:(AddressBookStyle)myStyle {
        _myStyle = myStyle;
        return;
        //>>>>>珠珠<<<<<<因为有return 走不到 if里面,所以注视了--0726
        if (myStyle == AddressBookStyleNoneFriend) {
            _topView.hidden = NO;
            
            _midView.hidden = NO;
            
            _defaultView.hidden = YES;
            
            _myHeightNum.constant = 113;
            
            _becameCodeBtn.hidden = YES;
            
            [_addSomeOneBtn setTitle:@"邀请好友加入" forState:UIControlStateNormal];
            
            _btnTopLabe.text = @"您的通讯录没有成员可加入项目";
            
            self.frame = CGRectMake(0, 0, kScreenWidth, 180);
            
        }else if(myStyle == AddressBookStyleHaveFriend) {
            _topView.hidden = NO;
            
            _midView.hidden = NO;
            
            _defaultView.hidden = YES;
            
            _myHeightNum.constant = 153;
            
            _becameCodeBtn.hidden = NO;
            
            [_addSomeOneBtn setTitle:@"从通讯录中导入" forState:UIControlStateNormal];
            
            _btnTopLabe.text = @"请导入讨论组成员";
            
            self.frame = CGRectMake(0, 0, kScreenWidth, 220);
        }else if (myStyle == AddressBookStyleDefault) {
            _topView.hidden = YES;
            
            _midView.hidden = YES;
            
            _defaultView.hidden = NO;
            
            self.frame = CGRectMake(0, 0, kScreenWidth, 95);
        }
        
    }
    

     因为有return,所以,if里面的永远都走不到。

    参考文档:https://stackoverflow.com/questions/30359236/if-statement-code-warning-code-will-never-be-executed-ios

  • 相关阅读:
    迷宫
    【NOIP2001普及组】最大公约数和最小公倍数问题
    latex online tool
    连续自然数和
    又是毕业季Ⅰ
    区间素数
    【AHOI2005】约数研究
    【NOIP2011提高组】计算系数
    【NOIP2012普及组】寻宝
    plsql 导出oracle数据库
  • 原文地址:https://www.cnblogs.com/lyz0925/p/7241032.html
Copyright © 2020-2023  润新知