I am creating a class to manage the checkboxes.
This is what I did:
import UIKit
class CheckboxButton: UIButton {
//let checked = ""
//let unchecked = ""
let checked = "bubu"
let unchecked = "baba"
var isChecked:Bool = false{
didSet{
if isChecked == true {
self.setTitle(checked, forState: UIControlState.Normal)
}else{
self.setTitle(unchecked, forState: UIControlState.Normal)
}
}
}
override func awakeFromNib() {
self.titleLabel?.font = UIFont(name: "FontAwesome", size: 20)
self.addTarget(self, action: "buttonClicked", forControlEvents: UIControlEvents.TouchUpInside)
self.isChecked = false
}
func buttonClicked(sender:UIButton){
if(sender == self){
if isChecked == true {
isChecked = false
}else{
isChecked = true
}
}
}
}
Everything is fine, but when I click on the button, the app just crashes with error Thread 1: signal SIGABRT
Is there something wrong?
Thanks for any help!