Swift仿制药推迟了问题

Swift仿制药推迟了问题,第1张

概述我正在努力做到这一点,但我遇到了一些麻烦 这是CustomProtocol protocol CustomProtocol {} SubCustomProtocol protocol SubCustomProtocol: CustomProtocol {} SubCustomProtocolImplementation class SubCustomProtocolImplementati 我正在努力做到这一点,但我遇到了一些麻烦

这是CustomProtocol

protocol CustomProtocol {}

SubCustomProtocol

protocol SubCustomProtocol: CustomProtocol {}

SubCustomProtocolimplementation

class SubCustomProtocolimplementation: SubCustomProtocol {}

这是CustomClass

class CustomClass<P: CustomProtocol> {    var customProtocol: P?    func doSomething() {    } }

SubCustomClass

class SubCustomClass<P: SubCustomProtocol>: CustomSubClass {}

和我的BaseVIEwController

class BaseVIEwController<P: CustomProtocol,T: CustomClass<P>>: UIVIEwController {    var foo: T!    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        foo?.doSomething()    }}

我的VIEwController

class VIEwController<P: SubCustomProtocolimplementation,T: SubCustomClass<P>>: BaseVIEwController<P,T> {    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()    }}

在我称之为foo?.doSomething()的行中,它表示’T’不是’CustomClass<'P'>‘的子类型我不知道我做错了什么

在VIEwController声明中,它表示“BaseVIEwController需要
T继承自CustomClass<'P'>“

希望你能帮我!

解决方法 如果要将foo var类型指定为CustomClass< P>你应该这样做.

class VIEwController<P: CustomProtocol>: UIVIEwController {    var foo: CustomClass<P>?    overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        foo?.doSomething()    }}
总结

以上是内存溢出为你收集整理的Swift仿制药推迟了问题全部内容,希望文章能够帮你解决Swift仿制药推迟了问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1018437.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存