<div dir="ltr">Hmm... would it be possible to define a protocol like "UnifiedURLType", define each of the properties you need to work with inside your extension functions as protocol properties inside the protocol UnifiedURLType {} declaration, create an extension UnifiedURLType {} and include doSomething() inside the extension, and then create extensions on both URL and NSURL causing them to conform to UnifiedURLType? (extension URL: UnifiedURLType {}; extension NSURL: UnifiedURLType {})<div><br></div><div>You could try it, but I wouldn't hold my breath, especially if you're planning on using absoluteURL within your extension as something as basic as the type of that variable is already different between the two types. </div><div><br></div><div>Dennis</div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Nov 11, 2016 at 3:08 AM Fabian Ehrentraud via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi list,<br class="gmail_msg">
<br class="gmail_msg">
Since Swift 3 there exist overlay structs, e.g. NSURL gets bridged to URL.<br class="gmail_msg">
Unfortunately now extensions on URL are not getting bridged back to ObjC:<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
extension URL {<br class="gmail_msg">
func doSomething() -> URL {<br class="gmail_msg">
return self.absoluteURL<br class="gmail_msg">
}<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
+ (NSURL *)swiftStructExtensionCaller {<br class="gmail_msg">
NSURL *url = [NSURL URLWithString:@"<a href="https://apple.github.io/swift-evolution/" rel="noreferrer" class="gmail_msg" target="_blank">https://apple.github.io/swift-evolution/</a>"];<br class="gmail_msg">
return [url doSomething];<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
The compiler does not see the method `doSomething`. Is this on purpose, or something that has yet to be improved?<br class="gmail_msg">
<br class="gmail_msg">
I'm aware that I could write the extension on NSURL, but that would mean a lot of casting on the Swift side.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
-- Fabian<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>