Adding Two .swift files with same name to project

橙三吉。 提交于 2019-12-20 04:10:22

问题


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?


回答1:


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.)



来源:https://stackoverflow.com/questions/43230048/adding-two-swift-files-with-same-name-to-project

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