<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">The way @objc methods are added in an extension is by using Objective-C categories. With a generic class, though, there's no Class object to attach the category metadata to—it's all created dynamically at runtime.</div><div class=""><br class=""></div><div class="">We could potentially support this some day, but it would take some thought, and we'd have to be careful not to drastically slow down the cost of instantiating new concrete types from a heavily-extended generic class.</div><div class=""><br class=""></div><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 24, 2016, at 7:23, Zhao Xin via swift-users &lt;<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:georgia,serif">I was trying to implement a final class to conform NSCopying by extension. List&lt;T&gt; was a class in Realm object database.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">final class List&lt;T&gt;&nbsp;</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">My implementation:</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">extension List:NSCopying {</div><div class="gmail_default" style="font-family:georgia,serif">&nbsp; &nbsp;&nbsp;public func copy(with zone: NSZone? = nil) -&gt; Any {</div><div class="gmail_default" style="font-family:georgia,serif">&nbsp; &nbsp; &nbsp; &nbsp; ...</div><div class="gmail_default" style="font-family:georgia,serif">&nbsp; &nbsp; }</div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">I got an error called "@objc is not supported within extensions of generic classes.". Any idea why there is a limitation of this? Thanks.</div><div class="gmail_default" style="font-family:georgia,serif"><br class=""></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div>
_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></div></blockquote></div><br class=""></body></html>