【发布时间】:2018-05-27 08:08:46
【问题描述】:
我想为 UIView 创建一个基类,该基类要求委托符合 View 定义的特定协议。
class BaseView<P>: UIView {
weak var delegate: P?
}
protocol MyProtocol {}
class MyView: BaseView<MyProtocol> {}
这给了我错误:“'weak' must not be applied to non-class-bound 'T';考虑添加具有类绑定的协议一致性”。
如何解决此错误?或者有什么解决办法?还是一开始就没有必要让委托变量变弱?提前致谢。
【问题讨论】:
标签: ios swift generics delegates protocols