<div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">Thank you, Jordan.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 25, 2016 at 1:15 AM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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><br></div><div>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><br></div><div>Jordan</div><div><br></div><br><div><blockquote type="cite"><div><div class="h5"><div>On Aug 24, 2016, at 7:23, Zhao Xin via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div class="gmail_default" style="font-family:georgia,serif">I was trying to implement a final class to conform NSCopying by extension. List<T> was a class in Realm object database.</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">final class List<T> </div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">My implementation:</div><div class="gmail_default" style="font-family:georgia,serif"><br></div><div class="gmail_default" style="font-family:georgia,serif">extension List:NSCopying {</div><div class="gmail_default" style="font-family:georgia,serif"> public func copy(with zone: NSZone? = nil) -> Any {</div><div class="gmail_default" style="font-family:georgia,serif"> ...</div><div class="gmail_default" style="font-family:georgia,serif"> }</div><div class="gmail_default" style="font-family:georgia,serif">}</div><div class="gmail_default" style="font-family:georgia,serif"><br></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></div><div class="gmail_default" style="font-family:georgia,serif">Zhaoxin</div></div></div></div>
______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br></div></blockquote></div><br></div></blockquote></div><br></div>