Use property observers
Swift
var language: String = "ObjC" {
willSet(newValue) {
print("willSet \(language) to \(newValue)")
}
didSet(oldValue) {
print("didSet \(oldValue) to \(language)")
}
}
language = "Swift"
/* prints:
willSet ObjC to Swift
didSet ObjC to Swift
*/