Swift通用类继承
示例
通用类可以被继承:
//楷模 class MyFirstModel { } class MySecondModel: MyFirstModel { } //通用类 class MyFirstGenericClass<T: MyFirstModel> { func doSomethingWithModel(model: T) { //在这里做点什么 } } class MySecondGenericClass<T: MySecondModel>: MyFirstGenericClass<T> { override func doSomethingWithModel(model: T) { super.doSomethingWithModel(model) //在这里做更多的事情 } }