在同一ios项目中使用2个版本的AFNetworking

编程入门 行业动态 更新时间:2024-10-25 06:32:06
本文介绍了在同一ios项目中使用2个版本的AFNetworking的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个项目,我使用了AFNetworking 2.0(不是可可豆荚-只是添加到了项目中)

I have a project, where Ive used AFNetworking 2.0(not as cocoa pod - just added to project)

然后,我实现了日历MSCollectionViewCalendarLayout,封装在pod中的依赖项很少,其中一个是//'RestKit','〜> 0.22.0'//。 RestKit使用AFNetowrking 1.3,并将其打包在RestKit中。

Then, I've implemented calendar MSCollectionViewCalendarLayout, which has few dependencies packaged in a pod, one of which is // 'RestKit', '~> 0.22.0' //. RestKit uses AFNetowrking 1.3 and has it packaged within RestKit.

在使用日历时,我禁用了最初的AFNetworking 2.0代码,但是现在,当我微调日历时,我没有为Login auth(AFNetworking 2.0)添加注释代码,并且它停止了工作:

While working with calendar, I have disabled my initial AFNetworking 2.0 code, but now when i fine tuned the calendar, Ive uncommented code for Login auth(AFNetworking 2.0), and it stopped working:

operation.responseSerializer = [AFXMLParserResponseSerializer序列化器]; <-说没有这种属性。

operation.responseSerializer = [AFXMLParserResponseSerializer serializer]; <-- saying there is no such property.

两个AFNetworking库是否可以在同一个项目中共存?考虑到RestKit不能与AF 2.0一起使用,解决此问题的最佳方法是什么?

Is it possible for both AFNetworking libs to co-exist in the same project? What would be the best way to resolve this considering that RestKit does not work with AF 2.0?

非常感谢

推荐答案

如果要使用AFNetworking 2.x类,则需要导入AFNetworking 2.x标头,而如果要使用1.x标头,则需要导入1.x标头。

You'll need to import the AFNetworking 2.x headers when you want to use AFNetworking 2.x classes, and the 1.x headers when you want to use those.

如果您有一个同时需要这两个类的类,则需要将该类的功能分为两个单独的类。您还可以使用动态消息传递技巧来解决冲突,但这可能会变得棘手。

If you have one class that needs both, you'll need to split the functionality of that class into two separate classes. You could also use a dynamic messaging hack to resolve the conflict, but that would probably get icky.

您还可以尝试 RestKit的实验版本,支持AFNetworking 2 ,甚至对其开发有所贡献。

You could also try the experimental version of RestKit that supports AFNetworking 2, or even contribute to its development.

更多推荐

在同一ios项目中使用2个版本的AFNetworking

本文发布于:2023-11-06 22:48:58,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1564885.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:版本   项目   在同一   AFNetworking   ios

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!