Adding Two .swift files with same name to project(将两个同名的 .swift 文件添加到项目中)
问题描述
我正在尝试将 swagger 客户端集成到我的项目中.我能够从大摇大摆地生成课程.Swagger for swift 3 使用 Alamofire 进行其 newtork 操作.问题是生成的类名称之一是响应".Alamofire 内部具有相同的类.当我添加这些类并尝试构建时,我有很多错误抱怨重新声明类.在这种情况下我能做什么?我是否必须从服务器端更改才能获得响应"类?
I am trying to integrate swagger client in my project. I was able to generate classes from swagger. Swagger for swift 3 uses Alamofire for its newtork operations. The issue is one of the generated class name is 'Response'. Alamofire internally has the same class. When i add these classes and try to build I have many errors complaining about re-declaration of class. What can i do in this case? Should i have to change from my server side to not get 'Response' class?
推荐答案
您应该能够不理会他们的代码,只需将模块名称添加到您的调用中:
You should be able to leave their code alone and just add the module name to your calls:
Alamofire.Response.... Swagger.Response...
这样您的代码就不会模棱两可了.(编译器不会尝试猜测你的意思是哪一个,你给了它两种可能性......类开头的模块名称将使编译器清楚你想要哪个.)
so that your code is not ambiguous. (the compiler won't try to guess which one you mean, and you've given it two possibilities... the Module name at the beginning of the class will make it clear to the compiler which one you want.)
这篇关于将两个同名的 .swift 文件添加到项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将两个同名的 .swift 文件添加到项目中


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01