I’ve SwiftLint enabled in project and it throws an warning for below function :
override func observeValue(forKeyPath keyPath: String?, of _: Any?, change: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
. . .
}
Shell Script Invocation Warning : Block Based KVO Violation : Prefer the new block based KVO API with key paths when using Swift 3.2 or later.
Any fix for this?
A good tutorial to make Block Base KVO Here
class CounterModel : NSObject {
@objc dynamic var value = 0
@objc dynamic var messages = [String]()
}
model.observe(\.value, options: [.initial]) { (model, change) in
self.label.text = String(model.value)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With