Category 命名冲突检测

来源:互联网 发布:美的面试 知乎 编辑:程序博客网 时间:2024/06/06 00:43

参考

https://developer.apple.com/library/ios/qa/qa1908/_index.html#//apple_ref/doc/uid/DTS40016829


You can use the OBJC_PRINT_REPLACED_METHODS environment variable to enable extra debug logging that prints a message when methods are replaced by category implementations. When a category is loaded, a message similar to Listing 2 is printed for each method in the category that clashes with an existing method in the original class.

可以设置OBJC_PRINT_REPLACED_METHODS 环境变量来开启debug日志,开启后将会打印出某一方法何时被category实现方法替代了。当category被加载完成后,一条类似清单2展示的消息会被打印出来,这条消息表明了category中的哪一个方法与原始类中的方法名产生了冲突。

Listing 2  Log output when a method is replaced by a category implementation

objc[21184]: REPLACED: -[UIView isOccludedByView:] by category MyCategory (IMP was 0x1873728a0 (/System/Library/Frameworks
/UIKit.framework/UIKit), now 0x10002e700 (/var/mobile/Containers/Bundle/Application/14AFE8C4-EA96-4A51-8D40-F1DAD35CC3D8/<YourApplicationName>.app/<YourApplicationName>)

Important: You should ignore log messages that do not explicitly name your application or a custom framework it links against. Some system frameworks use categories to provide implementations of methods that are defined as stubs in the original class. This causes extra log messages to be emitted when running with the OBJC_PRINT_REPLACED_METHODS environment variable enabled and is expected behavior.

重要提示:你应该忽略那些和你的程序、自定义框架无关的消息。一些系统库使用category来实现原始类中定义的某些方法。当设置OBJC_PRINT_REPLACED_METHODS环境变量为真得时候,请忽略因为上述原因产生的多余日志,因为这是正常行为

0 0