Same class extension in two different modules

别等时光非礼了梦想. 提交于 2019-12-01 16:33:36

问题


I have a framework in my project that implements an extension on NSDate. The extension looks like this.

extension NSDate {
   func isGreaterThanDate(otherDate: NSDate) -> Bool {
      //function implementation here
   }
}

I've imported this framework into an app project. Now if I copy and paste that same extension into a swift file in the app, the new copy in my app's code appears to override the copy in the framework's code.

When I'm calling this function in my app, is there a way I can use namespacing to specify which implementation I want?


回答1:


The only answer I've found so far "No you can't use namespacing to protect against this." But I'm still keeping my eyes open for how to handle this situation if someone uses the same function signature like this accidentally.



来源:https://stackoverflow.com/questions/33534371/same-class-extension-in-two-different-modules

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