Tag: 快速协议

generics协议,types为Swift

我如何创建一个协议variables。 我的目标是一个协议将有一个genericstypes的函数,我正在使用正在访问Class associatedtypetypes,该函数将返回genericstypes。 下面的示例声明: public protocol ComponentFactory { associatedtype T // A class and that class can be inherit from another so I need define generic type here func create() -> T } 我想为这个协议声明一个variables: fileprivate var mComponentFactoryMap = Dictionary() 在这一行,我收到一个错误: Protocol ‘ComponentFactory’ can only be used as a generic constraint because it has Self or […]