如何修复swift 3嵌套泛型错误

时间:2017-11-07 17:01:36

标签: swift generics inheritance

以下代码

https://i.stack.imgur.com/07Jry.png

class BaseModel {

}

class BaseView<T: BaseModel> {

}

class BaseController<T: BaseView<BaseModel>> {

}

class MarketModel: BaseModel {

}

class InfoModel: BaseModel {

}

class MarketView: BaseView<MarketModel> {

}

class InfoView: BaseView<InfoModel> {

}

class MarketViewController: BaseController<MarketView> {

}

class InfoViewController: BaseController<InfoView> {

}

我收到了这样的错误消息

'BaseController'要求'MarketView'继承自'BaseView'

'BaseController'要求'InfoView'继承自'BaseView'

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我使用以下代码解决了这个错误:

console.log($filter('date')(new Date($scope.myDate),'yyyy-MM-dd'))