将两个具有相同名称的.swift文件添加到项目中 [英] Adding Two .swift files with same name to project

查看:134
本文介绍了将两个具有相同名称的.swift文件添加到项目中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将swagger客户端集成到我的项目中。我能够从swagger生成类。 swagger for swift 3使用Alamofire进行新的操作。问题是生成的类名称之一是'Response'。 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文件添加到项目中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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