Reputation: 13
in this case, i'm using:
- (IBAction)reset:(id) sender {
if ((boxHide1.hidden = YES) && (boxHide2.hidden = YES)) {
resetHide.hidden = NO;
}
}
How can I do this? I have 12 items all together I need in the statement. Thanks!
Upvotes: 0
Views: 1283
Reputation: 18670
You could use the solution @Joe posted but as you can tell the code for hiding / unhiding could get very messy and hard to read.
If you want to keep your code clean and easy to understand / maintain, I'd put all these buttons into a NSMutableArray and iterate through it to determine whether you want to show the reset button or not.
BOOL showResetButton = YES;
for (UIButton *button in buttonsArray)
{
if (button.hidden == NO) // If any of the buttons is not hidden do not show the reset button
showResetButton = NO;
}
resetButton.hidden = showResetButton;
Upvotes: 3
Reputation: 57169
Make sure you use ==
to compare values but since they are already booleans you do not need to compare against YES
. If all the comparisons are AND(&&
) that is correct and you can drop the parenthesis, otherwise if there are any OR(||
) operations then you would need to group the appropriate operations.
if (boxHide1.hidden &&
boxHide2.hidden &&
... &&
boxHide12.hidden)
{
resetHide.hidden = NO;
}
Upvotes: 2