我具有此设置来观察AVCaptureDevice deviceWhiteBalanceGains的值更改:
@objc dynamic var videoDevice:AVCaptureDevice?
private var deviceWBGainsObservation: NSKeyValueObservation?
然后在代码中,
deviceWBGainsObservation = videoDevice?.observe(\.deviceWhiteBalanceGains,
options: [.old, .new]) {[unowned self] (object, change) in
NSLog("\(change)")
}
问题是更改oldValue,而newValue始终为nil。如果我使用传统的键值观察方法observeValue(forKeypath:...)
,则不是这种情况。我在做什么错了?