2017-10-20 77 views
-3
@IBAction func blueBtnAct(_ sender: AnyObject) { 
    score++ //error bcause Unary operator '++' cannot be applied to an operand of type '@lvalue Int' 
    blueLbl.text = "\(score)" 
    GrenLbl.text = "\(score)" 
    testScore() 
} 
@IBAction func GrenBtnAct(_ sender: AnyObject) { 
    score-- //error bcause Unary operator '--' cannot be applied to an operand of type '@lvalue Int' 
    blueLbl.text = "\(score)" 
    GrenLbl.text = "\(score)" 
    testScore() 
} 

回答

4

您应该使用的,而不是score++

+1

的推荐替代使用score = score + 1是'得分+ = 1' – vadian

+0

是你right @vadian但是score = score + 1易于学习 – Zee

+0

不,学习正确的东西。谁能理解'++'也会理解'+ = 1' ;-) – vadian

相关问题