在iOS 8框架中使用类别 [英] Using categories in iOS 8 frameworks

查看:109
本文介绍了在iOS 8框架中使用类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用框架在应用和扩展之间共享一些代码。大多数情况下这是有效的,但我有几个类似乎没有在扩展中正确加载。例如,我在NSString上有一个类别来反转目标字符串,但是当我尝试在扩展中使用该选择器时,我的代码陷入无法识别的选择器异常。我尝试添加-all_load链接器标志,首先只是框架,然后是扩展,尝试强制加载框架中实现的所有类,但这似乎不起作用。

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

推荐答案

如果我没记错的话,你需要在使用你的库/框架的父项目中的其他链接器标志中设置-ObjC。 -all_load用于修复-ObjC中的错误,这不再需要了。

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.

这篇关于在iOS 8框架中使用类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆