Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Same class extension in two different modules

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?

like image 259
Cruinh Avatar asked Nov 04 '15 23:11

Cruinh


1 Answers

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.

like image 157
Cruinh Avatar answered Nov 04 '22 09:11

Cruinh