Xcode warning: code will never be executed.

在xcode編譯的時候,提示了code will never be executed這個警告。百度了一下,大致的意思是,該代碼永遠不會執行的意思。ios

好比:xcode

- (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裏面的永遠都走不到。code

參考文檔:https://stackoverflow.com/questions/30359236/if-statement-code-warning-code-will-never-be-executed-iosorm

相關文章
相關標籤/搜索