[swift-users] question on generics

davelist at mac.com davelist at mac.com
Wed Feb 22 18:08:04 CST 2017


I suspect this can't be done (at least not right now), but wanted to check.

I'd like to declare a class as a generic that meets a protocol and is also a subclass of some specific type.

Something like class Foo<T:NSManangedObject,SomeProtocol> (i.e., the T must be both a NSManagedObject or subclass of it and conform to SomeProtocol).

Is this possible?

Thanks,
Dave Reed



More information about the swift-users mailing list