是否可以在objective-c中在运行时注册KVO相关键?

前端之家收集整理的这篇文章主要介绍了是否可以在objective-c中在运行时注册KVO相关键?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
会改变(NSSet *)keyPathsForValuesAffecting< Key>的输出在运行时影响依赖键?换句话说,这个方法调用的频率/时间是多少?

解决方法

the docs给我指示keyPathsForValuesAffecting< Key>只有在设置观察时才会调用.

When an observer for the key is registered with an instance of the receiving class,key-value observing itself automatically observes all of the key paths for the same instance,and sends change notifications for the key to the observer when the value for any of those key paths changes.

在许多情况下,您可以使用KVO本身来通知您的观察者keyPathsForValuesAffecting< Key>已经改变.一些自定义键的手动willChangeValueForKey和didChangeValueForKey通知将是处理动态更改键的一种方法.

猜你在找的C&C++相关文章