1
비슷한 유형의 단추가 있습니다. 유일한 차이점은 이름 끝에 추가 된 정수입니다.보기 이름이 붙은 문자열 추가
코드 스 니펫 :
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)")
}
위 코드는 변환 오류를 발생시킵니다.
'SSRadioButtonsController' 배열을 사용할 수 있습니다. – Code
@ Code 같은가요? 'var radioButtonController : [SSRadioButtonsController] = []' – user2640921
예. ////////// – Code