我目前正在 Xcode 8 中编写 Swift 3 代码。
使用时oldValue
and newValue
里面的默认参数willSet
and didSet
块,我得到"unresolved identifier"
编译器错误。
我有一个非常基本的代码如下
var vc:UIViewController? {
willSet {
print("Old value is \(oldValue)")
}
didSet(viewController) {
print("New value is \(newValue)")
}
}
Swift 3 似乎仍然支持这些功能。
我希望我在这里没有遗漏任何东西?
您还可以使用vc
:
var vc:UIViewController? {
willSet {
print("New value is \(newValue) and old is \(vc)")
}
didSet {
print("Old value is \(oldValue) and new is \(vc)")
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)