Using categories in iOS 8 frameworks

混江龙づ霸主 提交于 2019-12-10 11:15:42

问题


I am trying to share some code between an app and an extension, using a framework. Mostly this works, but I have several categories that do not seem to load correctly in the extension. For example, I have a category on NSString to reverse the target string, but when I try to use that selector within the extension my code traps with an "unrecognized selector" exception. I tried adding the "-all_load" linker flag, first to just the framework, and then to the extension, to try and force load all the classes implemented in the framework, but this does not seem to work.

Any suggestions would be most welcome...

-David


回答1:


If I remember correctly you need to set -ObjC in other linker flags in the parent project that is using your library/framework. The -all_load was being used to fix a bug in the -ObjC one, this is not needed anymore.



来源:https://stackoverflow.com/questions/26122210/using-categories-in-ios-8-frameworks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!