In Objective-C, I could declare a class a subclass and conform to a protocol:
@interface SubClass : ParentClass<OneProtocol>
When bridged to Swift 1.x, SubClass
becomes
class SubClass : ParentClass, OneProtocol
I find it difficult to use this kind of composite type. For example, without using generics, how to say a function returns an instance of a ParentClass
that conforms to OneProtocol
?
I know if it is two protocols, we can use protocol<OneProtocol, TwoProtocol>
. But here one of them is class.
Ideally there is a syntax to declare this as a typealias. But if it is not possible, the last resort is to compose in Objective-C, and bridge the composition to Swift.