저는이 문제를 하루 동안 알아 내려고 노력해 왔으며 수정 사항을 찾을 수없는 것 같습니다. 내가 할 노력하고있어목표 C if 문이 작동하지 않습니다.
int person;
-(IBAction)personOne:(id)sender{
[twoPerson stopAnimating];
[fourPerson stopAnimating];
[threePerson stopAnimating];
[onePerson startAnimating];
person = 1;
}
-(IBAction)personTwo:(id)sender{
[threePerson stopAnimating];
[fourPerson stopAnimating];
[onePerson startAnimating];
[twoPerson startAnimating];
person = 2;
}
-(IBAction)personThree:(id)sender{
[fourPerson stopAnimating];
[onePerson startAnimating];
[twoPerson startAnimating];
[threePerson startAnimating];
person = 3;
}
-(IBAction)personFour:(id)sender{
[onePerson startAnimating];
[twoPerson startAnimating];
[threePerson startAnimating];
[fourPerson startAnimating];
person = 4;
}
이 버튼 다음 클릭하면 사람이 정수 값과 동일하다.
이 코드에 전혀 문제가 나타나지 않습니다.
if 문을 사용하는 또 다른 버튼이 있습니다.
-(IBAction)go:(id)sender{
ammountDueFloat = ([ammountDue.text floatValue]);
tipPercent1;
findAmmount = tipPercent1 * ammountDueFloat;
NSString *showAmmountText = [[NSString alloc]initWithFormat:@"$%.2f", findAmmount];
showammount.text = showAmmountText;
if (person = 1) {
showPerPerson = findAmmount/1;
perPersonLabel.text = [[NSString alloc]initWithFormat:@"$%.2f", showPerPerson];
}
if (person = 2) {
showPerPerson = findAmmount/2;
perPersonLabel.text = [[NSString alloc]initWithFormat:@"$%.2f", showPerPerson];
}
if (person = 3) {
showPerPerson = findAmmount/3;
perPersonLabel.text = [[NSString alloc]initWithFormat:@"$%.2f", showPerPerson];
}
if (person = 4) {
showPerPerson = findAmmount/4;
perPersonLabel.text = [[NSString alloc]initWithFormat:@"$%.2f", showPerPerson];
}
else {
showPerPerson = findAmmount/1;
perPersonLabel.text = [[NSString alloc]initWithFormat:@"$%.2f", showPerPerson];
}
}
I 버튼 '이동'항상 사람의 가치를 가정을 클릭 할 때마다
문 경우 마지막이다.아이디어가 있으십니까?
당신이 '사용할 때 Xcode4 당신에게 = 경고를 표시합니다 '연산자를 호출합니다. 경고에 유의해야합니다. – Shreesh
비교 연산자는 대입 연산자 (==)를 사용하고 대입 연산자 (=)는 사용하지 않아야합니다. – EmptyStack
C에서 일부 수업을 듣고 ... 비교할 값을 지정하고 있습니다 !! – Aditya