看起来像weak references will be disallowed in protocols。那么,如果我想添加一个弱引用,我该怎么办呢?还有更好的主意吗?
protocol PipelineElementDelegate: class {
func someFunc()
}
protocol PipelineElement {
weak var delegate: PipelineElementDelegate? { get set}
}
答案 0 :(得分:12)
只需从协议中删除weak
关键字,然后在符合类型中将属性声明为弱:
class SomeClass: PipelineElement {
weak var delegate: PipelineElementDelegate?
}