I have similar type of buttons, the only difference they have is the integer appended at the end of name.
Code snippet:
radioButtonController1 = SSRadioButtonsController(buttons: radioBtn1,radiobtn2)
radioButtonController1!.delegate = self
radioButtonController1!.shouldLetDeSelect = false
radioButtonController2 = SSRadioButtonsController(buttons: radioBtn3,radioBtn4)
radioButtonController2!.delegate = self
radioButtonController2!.shouldLetDeSelect = false
radioButtonController3 = SSRadioButtonsController(buttons: radioBtn5,radioBtn6,radioBtn7)
radioButtonController3!.delegate = self
radioButtonController3!.shouldLetDeSelect = false
radioButtonController4 = SSRadioButtonsController(buttons: radioBtn8,radioBtn9)
radioButtonController4!.delegate = self
radioButtonController4!.shouldLetDeSelect = false
Now, I want to do this in a single loop, to reduce the code. Is there any way, I can do it in a loop? Like create a variable and addd an integer at the end, something like below:
for index in 1...11 {
radioButtonController = radioButtonController.append("\(index)")
}
Above code throws a conversion error.
SSRadioButtonsController.var radioButtonController: [SSRadioButtonsController] = []