KVO not working: message was received but not handled

后端 未结 1 1567
南方客
南方客 2021-01-26 01:53

I got the following error when playing around with KVO. Does it only work with subclasses of UIViewController?

Terminating app due to uncaught exception \'NSInte         


        
相关标签:
1条回答
  • 2021-01-26 02:03

    According to the docs, the name of the method is observeValue(forKeyPath:of:change:context:). Note of:, not ofObject: as you have. Your method is not an implementation of the required method. I believe you'll need to mark the properly-named method with override (and the fact that the compiler let you get away without that was a sign that you had the name wrong).

    0 讨论(0)
提交回复
热议问题