I converted my project to Swift 3.0 and I get this error at the
for
func removeButton(_ aButton: UIButton) {
var iteration = 0
var iteratingButton: UIButton? = nil
for( ; iteration<buttonsArray.count; iteration += 1) {
iteratingButton = buttonsArray[iteration]
if(iteratingButton == aButton) {
break
} else {
iteratingButton = nil
}
}
if(iteratingButton != nil) {
buttonsArray.remove(at: iteration)
iteratingButton!.removeTarget(self, action: #selector(SSRadioButtonsController.pressed(_:)), for: UIControlEvents.touchUpInside)
if currentSelectedButton == iteratingButton {
currentSelectedButton = nil
}
}
}
It's a clear error, Swift 3 does NOT support the c-style for
loop.
Instead, you should:
for iteration in 0 ..< buttonsArray.count {
iteratingButton = buttonsArray[iteration]
if(iteratingButton == aButton) {
break
} else {
iteratingButton = nil
}
}
You should check Apple's Documentation.