我已经在项目中启用了SwiftLint,它为下面的函数抛出一个警告:
override func observeValue(forKeyPath keyPath: String?, of _: Any?, change: [NSKeyValueChangeKey: Any]?, context _: UnsafeMutableRawPointer?) {
. . .
}

Shell脚本调用警告:基于块的KVO违规:在使用SWIFT3.2或更高版本时,更倾向于新的基于块的KVO和密钥路径。
有什么解决办法吗?
发布于 2018-12-25 22:23:12
一个制作块基KVO 这里的好教程
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)
}https://stackoverflow.com/questions/49747536
复制相似问题