0

I need to add a protocol which contains associatedtype as a property in another protocol, such like:

ProtocolA (contains associatedtype)

public protocol ProtocolA {
    associatedtype T
    func func1() -> T
}

And I want to have another protocol contains a ProtocolA object as a property, like this:

public protocol ProtocolB {
    var parameter: ProtocolA { get }
}

Then I got an issue from Xcode:

Protocol 'ProtocolA' can only be used as a generic constraint because it has Self or associated type requirements

I know I have to specific a type for ProtocolA's associatedtype, but how to do it?

Any idea will be appreciated

Alanc Liu
  • 1,294
  • 10
  • 15

0 Answers0