Ios 用视图名称追加字符串

Ios 用视图名称追加字符串,ios,swift,Ios,Swift,我有类似类型的按钮,它们唯一的区别是名称末尾附加了整数 代码段: radioButtonController1 = SSRadioButtonsController(buttons: radioBtn1,radiobtn2) radioButtonController1!.delegate = self radioButtonController1!.shouldLetDeSelect = false radioButtonController2 = SSRadioButtonsControl

我有类似类型的按钮,它们唯一的区别是名称末尾附加了整数

代码段:

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
现在,我想在一个循环中这样做,以减少代码。有没有办法,我可以循环完成?如创建一个变量并在末尾添加一个整数,如下所示:

for index in 1...11 {
    radioButtonController = radioButtonController.append("\(index)")
}

上面的代码抛出了一个转换错误。

我认为没有任何方法可以按照您的方式做您想做的事情


您可以将所有单选按钮放入一个数组中,然后在枚举时使用数组索引来查找所需的按钮。

您可以使用
ssradiobuttonscoller
数组。类似于@code<代码>var radioButtonController:[SSRadioButtonController]=[]但这并没有回答我关于在视图名称末尾添加整数的问题