Swift 3 equivalent for Java property with type that implements specific interface

  1. 9 months ago

    Please help translate following Java code into Swift 3:

    interface A {
    }
    
    class BiA implements A {
    }
    
    interface C {
        List<? extends A> getAs();
    }
    
    class D implements C {
        List<BiA> getAs();
    }

    The problem I'm facing is with protocol C. I don't know how to declare the protocol, I don't know how to represent "? extends A" in Swift. I'm happy to use built-in Swift arrays. All I want is to be able to use class BiA in D where the getAs() implements the protocol method from C. It's odd that such a simple construct is so hard to get an answer for, not in any Apple guides nor in any forums.

or Sign Up to reply!