FS.O5 FS.O5 - 3 months ago 11
Swift Question

Set an array of IBObjects

I have a xib file that has 10

UIButton
s in it.

I need to change the color of a random button every second.

Is the only way is to create an individual IBOutlet to every button and then create an array in
ViewDidLoad
with these button or is there any way I can create an array of all the buttons straight from
Interface Builder
?

Thank you!

Answer

Sure, you can create an IBOutletCollection instead of IBOutlets :

IBOutletCollection

Then you can add buttons to this collection by drawing the + symbol to each button :

Plus button

Have fun!