If I have a large number of buttons set up in Interface Builder, how can I place them into an array via code?
For example, if I have three buttons and in the interface file I define them:
@property (nonatomic, retain) IBOutlet UIButton *button1;
@property (nonatomic, retain) IBOutlet UIButton *button2;
@property (nonatomic, retain) IBOutlet UIButton *button3;
If I want to rename each of these buttons to say “Hello”, I want to be able to lump them into an array and then use a function such as:
for (int i = 0; i < someArray.count; i++)
{
someArray[i].text = @"Hello";
}
Could someone please provide information on how this is achieved (if it’s possible)?
Thanks
Assuming the buttons in IB are correctly wired to the IBOutlet properties then its as straightforward as: