美文网首页
Swift初入报错归总

Swift初入报错归总

作者: 大写的空气 | 来源:发表于2021-06-21 17:36 被阅读0次
Default argument not permitted in a protocol method(删除默认参数 = nil )
协议中实现默认参数造成报错
Extensions must not contain stored properties
扩展中定义存储属性报错

对RxSwift进行简单封装,需要使用到PublishSubject对象与DisposeBage,理想实现是所有工作都在协议层完成,直接遵循协议即可快速使用。既然协议本身限制实现不了,那么我们就绕个弯实现

//增加中间对象,协议中直接使用
struct rx {
    static var subject: PublishSubject<Any> = PublishSubject()
    static var disposeBag: DisposeBag = DisposeBag()
}

相关文章

网友评论

      本文标题:Swift初入报错归总

      本文链接:https://www.haomeiwen.com/subject/pqvyyltx.html