设置observeValueForKeyPath观察模式时报错
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<WDChat.WDVideoPlayView: 0x7f8ae1833b20; frame = (0 0; 390 844); layer = <CALayer: 0x6000028f9660>>: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: status
主要是这句
An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
由于刚刚开始学习,在实现observeValue时多余写了calss,所以标识没有实现该方法
override class func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
}
换成如下即可解决
override func observeValue(forKeyPath keyPath: String?, of object: Any?, change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
}
网友评论