Reputation: 115
I'm trying to use didSet
on a static observed property but it's not running the if-else statement in the didSet
. Here is the code:
static var isCorrect: Bool = false {
didSet {
if isCorrect {
ViewController.theViewController.checkbox.image = UIImage(named: "tick")
} else {
ViewController.theViewController.checkbox.image = nil
}
}
}
static var theViewController = ViewController()
It is all in a class called ViewController
. I'm changing the isCorrect
variable in another view controller class and dismissing it after that but it doesn't seem to work.
The checkbox
property used there is a variable of type UIImageView
.
Am I doing anything wrong? If I am then what is the right way?
Upvotes: 1
Views: 141