gpt4 book ai didi

swift - 如何修复 swift 3 嵌套的一般错误

转载 作者:行者123 更新时间:2023-11-28 07:59:11 25 4
gpt4 key购买 nike

下面的代码

/image/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'

我该如何解决这个问题?

最佳答案

我用下面的代码解决了这个错误:

class BaseModel {

}

class BaseView<T: BaseModel> {

}

class BaseController<T, U: BaseView<T>> {

}

class MarketModel: BaseModel {

}

class InfoModel: BaseModel {

}

class MarketView: BaseView<MarketModel> {

}

class InfoView: BaseView<InfoModel> {

}

class MarketViewController: BaseController<MarketModel, MarketView> {

}

class InfoViewController: BaseController<InfoModel, InfoView> {

}

关于swift - 如何修复 swift 3 嵌套的一般错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47163509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com