美文网首页
An -observeValueForKeyPath:ofObj

An -observeValueForKeyPath:ofObj

作者: 东方诗空 | 来源:发表于2022-03-11 15:55 被阅读0次

设置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?) {
}

相关文章

网友评论

      本文标题:An -observeValueForKeyPath:ofObj

      本文链接:https://www.haomeiwen.com/subject/sizcdrtx.html