“oldValue” and “newValue” default parameters names inside willSet / didSet unrecognized

后端 未结 6 1453
梦谈多话
梦谈多话 2021-02-06 21:44

I am currently writing Swift 3 code in Xcode 8.

When using oldValue and newValue default parameters inside the willSet and

6条回答
  •  情歌与酒
    2021-02-06 22:17

    You didn't try to initialize the variable with a new object by which you can set your clojure:

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

提交回复
热议问题