我需要创建一个字典变量,其中我的值将属于SomeOtherClass
类并符合SomeProtocol
. 这等于 Objective-C 中的以下声明:
NSMutableDictionary<SomeClass *, SomeOtherClass<SomeProtocol> *> *someOtherBySome;
那么,是否可以使用 Swift 以同样简单的方式做到这一点?
我需要它,因为我可以func
使用签名创建:
func someFunc<T: SomeOtherClass where T: SomeProtocol>(param: T, otherParam: String)
我想在没有类型转换的情况下获取param
参数的值。Dictionary