I have created 4 buttons via Interface Builder. I have an array which has the following content stored in it
"A"
"B"
"B"
"A"
Now what i need to do is to read the array of strings and paint the button Yellow or Red. If the String is A then the button should be Yellow, and if the String character is B the button should be Red.
My code so far;
for (NSString* content in arr) {
if ([content isEqualToString:@"A"]){
// Make the (1st/there after) button in the interface builder to Yellow and etc
}else {
// Make the 1st button in the interface builder to Redand etc
}
}
First, in Interface Builder (IB) you need to assign tag’s to each button that you want to change so that you can retrieve them later. Set the first button tag to 0, second to 1, etc.
Then your code would look something like this: