看起来像weak references will be disallowed in protocols。如果我想添加一个弱引用,我该怎么做呢?有更好的主意吗?
protocol PipelineElementDelegate: class {
func someFunc()
}
protocol PipelineElement {
weak var delegate: PipelineElementDelegate? { get set}
}
看起来像weak references will be disallowed in protocols。如果我想添加一个弱引用,我该怎么做呢?有更好的主意吗?
protocol PipelineElementDelegate: class {
func someFunc()
}
protocol PipelineElement {
weak var delegate: PipelineElementDelegate? { get set}
}
2条答案
按热度按时间z6psavjg1#
只需从协议中删除
weak
关键字,并在符合类型中将属性声明为weak:vc6uscn92#
将'objc'添加到协议定义和具体类类型中,您可以在协议中使用'weak'。还要确保具体类符合NSObject,即