Apple称whiteBalanceMode
的exposureMode
和AVCaptureDevice
属性是可观察到的KVO。
这是我在Objective-C工作了十年之后第一次在Swift编程。
在Swift中,KVO似乎更复杂。
我试过这个:
var kvoWhiteBalanceObserving : NSKeyValueObservation?
@objc var capDevice : AVCaptureDevice?
稍后的...
capDevice = captureDevice
self.kvoWhiteBalanceObserving = observe(\.capDevice.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}
Xcode指向\.
说:
如果没有更多的上下文,表达的类型是不明确的
如何在快速4中使用KVO?
像这样观察:
self.kvoWhiteBalanceObserving = capDevice?.observe(\.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}