So I have two checkBoxes. They are outlets. They are called catCheckBox and dogCheckBox. One day there might be added a birdCheckBox. The implementation of checkBox you can find beneath:
If I hit dogCheckBox I want to uncheck the catCheckBox and the birdCheckBox. I'm already considering a collectionView but it's not in a collectionView at the moment. Anyhow. I was trying to go
Xcode is throwing me error after error. For instance VC has no member dogCheckBox. Why is that?
Code:
class CheckBox: UIButton {
// Images
let checkedImage = UIImage(named: "check")! asUIImage
let uncheckedImage = UIImage(named: "shapes")! asUIImage
// Bool property
var isChecked: Bool = false {
didSet{
if isChecked == true {
self.setImage(checkedImage, forState: .Normal)
} else {
self.setImage(uncheckedImage, forState: .Normal)
}
}
}
override func awakeFromNib() {
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
}
}
}
}
If I hit dogCheckBox I want to uncheck the catCheckBox and the birdCheckBox. I'm already considering a collectionView but it's not in a collectionView at the moment. Anyhow. I was trying to go
Code:
var dogChecked = self.dogCheckBox.isChecked {
didSet {
self.uncheckOtherCheckBoxes()
}
}