"oldValue" and "newValue" default parameters names inside willSet / didSet unrecognized

You can also use vc:

var vc:UIViewController? {
    willSet {
        print("New value is \(newValue) and old is \(vc)")
    }
    didSet {
        print("Old value is \(oldValue) and new is \(vc)")
    }
}

The special variable newValue only works within willSet, while oldValue only works within didSet.

The property as referenced by its name (in this example vc) is still bound to the old value within willSet and is bound to the new value within didSet.


var vc:UIViewController? {
    willSet {
        print("New value is \(newValue)")
    }
    didSet {
        print("Old value is \(oldValue)")
    }
}

It's important to know that the special variable newValue only works within willSet, while oldValue only works within didSet.

var vc: UIViewController? {
    willSet {
        // Here you can use vc as the old value since it's not changed yet
        print("New value is \(newValue)")
    }
    didSet {
        // Here you can use vc as the new value since it's already DID set
        print("Old value is \(oldValue)") 
    }
}