Reputation: 85
Is there a way for swift code to check if this variable changes and than change the shape of an object?
var Shape = 0.4
let a = (self.size.width + self.size.height) * Shape
Upvotes: 0
Views: 710
Reputation: 768
Using property observers you can achieve what you are looking for. didSet
will be called after varibale value changed.
var variable1 = 0 {
didSet {
onValueChange()
}
}
func onValueChange() {
print("Change \(variable1)")
}
Upvotes: 2