I want to have three sets of 10 buttons for an iOS app. I want to show/hide each set (reveal one set at a time). I am planning to use tags to do this.
As it is I have a property for each button (ex: btn01, btn02, etc), so I have 30 properties. I add that to an array, and then use the following code to hide buttons with one tag or the other.
My question is, is there a more efficient way to create the array of objects, rather than setting up 30 properties (one for each button). It's fine, just wonder if there is a cleaner way, using a loop to gather each button from IB somehow. Can't think of it.
if (tagState == 1) {
tagState = 2;
}else {
tagState = 1;
}
for (btn in myArray) {
NSLog(@"%@",btn);
if (tagState == 1) {
if (btn.tag == 1) {
[btn setHidden:YES];
}
if (btn.tag == 2) {
[btn setHidden:NO];
}
} else if (tagState == 2) {
if (btn.tag == 1) {
[btn setHidden:NO];
}
if (btn.tag == 2) {
[btn setHidden:YES];
}
}
}
}