@IBOutlet var button: UIButton!
func randomize(){
var x_axis:CGFloat = 8.0
var y_axis:CGFloat = 330.0
for selected_Synonym in selected_Synonyms {
button = UIButton.init(type: UIButtonType.custom) as UIButton
button.frame = CGRect(x: x_axis, y: y_axis, width: 400, height: 50)
button.backgroundColor = UIColor.black
button.setTitle(selected_Synonym as? String, for: UIControlState.normal)
button.setTitleColor(UIColor.white, for: [])
button.addTarget(self, action: Selector(("pressed:")), for: UIControlEvents.touchUpInside)
self.view.addSubview(button)
x_axis = 10.0
y_axis += 70.0
}
}
func pressed(sender: Any){
let buttonTitle = button.currentTitle
print(buttonTitle)
}
However when it runs and I press on a button I get the following error:
Thread 1: signal SIGABRT.
The program creates 5 buttons. I am new to swift and ios development would be very grateful if someone could help me out. Thank you.