Reputation: 36003
Apple says the properties whiteBalanceMode
and exposureMode
of AVCaptureDevice
are KVO observable.
This is my first time programming in Swift, after a decade working in Objective-C.
KVO appears to be way more complex in Swift.
I have tried this:
var kvoWhiteBalanceObserving : NSKeyValueObservation?
@objc var capDevice : AVCaptureDevice?
later on...
capDevice = captureDevice
self.kvoWhiteBalanceObserving = observe(\.capDevice.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}
Xcode points to the \.
saying:
Type of expression is ambiguous without more context
How to I KVO this in swift 4?
Upvotes: 0
Views: 405
Reputation: 1934
observe like this:
self.kvoWhiteBalanceObserving = capDevice?.observe(\.whiteBalanceMode, options: [.old, .new]) { object, change in
print(object.whiteBalanceMode)
}
Upvotes: 2