willSet和didSet没有在继承的属性上调用观察者

时间:2017-07-17 02:39:20

标签: ios swift

我在UISlider的子类中有这段代码:

//`value` is a property of the `UISlider` class that stores the current value of the slider
override var value: Float {
    willSet {
        print("willSet called")
    }
    didSet {
        print("didSet called")
    }
}

我有另一个print语句,在拖动滑块时打印value字段的值。 value字段显然正在发生变化,因为当我拖动它时,正在打印的字段的值会发生变化,但永远不会调用属性观察者。知道该领域如何变化,但财产观察者从未被调用过吗?

0 个答案:

没有答案