2
아래의 모든 값은 double 형이지만 스위치에는 정수 값이 필요합니다. 이 주변에 어쨌든 있습니까?Double in Switch 문 사용
switch(fivePercentValue){
case floor((5*fivePercentValue)/100):
fivePercent_.backgroundColor = [UIColor greenColor];
fivePercentLabel_.textColor = [UIColor greenColor];
break;
case ceil((5*fivePercentValue)/100):
fivePercent_.backgroundColor = [UIColor greenColor];
fivePercentLabel_.textColor = [UIColor greenColor];
break;
default:
fivePercent_.backgroundColor = [UIColor redColor];
fivePercentLabel_.textColor = [UIColor redColor];
break;
예 -'if' /'else if' /'else'. – Mac
평형에 대한 부동 소수점 비교는 절대로 좋은 생각이 아니므로 부동 소수점 위에 '전환'하는 것은 정말 나쁜 생각입니다. –
'case' 값은 컴파일 타임 상수 여야합니다. –