Quote:
Originally Posted by starwarsdevwookie59
Ok i figure this should be simple, but for the life of me I can't figure out how to make one action do something if different values are true, without using a BUNCH of if statements. Example:
if (float1 == 3){
action1;
}
if (float2 == 3){
action1;
}
But i want to put that into one code, so works like this:
if (float1 or float2 ==3){
action1;
}
Once again, I realize this should be easy, but I just can't seem to figure out the code. Any help would be much appreciated.
|
You just combine the if statements to form one expression:
if(float1 == 3 || float2 == 3){
action1;
}
|| means or && means and so you can combine statements. If they both must equal 3 (not just one) then you would use && instead of ||.
I would pick up a basic Objective-C textbook and skim through it. Will cover a bunch of the basics like this and will be great for future reference.