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.
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. Jordan > On Aug 24, 2016, at 7:23, Zhao Xin via swift-users <[email protected]> > wrote: > > I was trying to implement a final class to conform NSCopying by extension. > List<T> was a class in Realm object database. > > final class List<T> > > My implementation: > > extension List:NSCopying { > public func copy(with zone: NSZone? = nil) -> Any { > ... > } > } > > I got an error called "@objc is not supported within extensions of generic > classes.". Any idea why there is a limitation of this? Thanks. > > Zhaoxin > _______________________________________________ > swift-users mailing list > [email protected] > https://lists.swift.org/mailman/listinfo/swift-users
_______________________________________________ swift-users mailing list [email protected] https://lists.swift.org/mailman/listinfo/swift-users
