[英]How to assign a weak reference outside of the header file?
self.locationSearchBar.delegate = self;
I believe I have a retain cycle occurring here, and I can't for the life of me remember how to give the delegate a weak reference to self. 我相信我这里有一个保留周期,我无法终生记住如何给代表弱引用自我。 Can someone tell me how to get this done?
有人可以告诉我如何完成这项工作吗?
If locationSearchBar
is an instance of UISearchBar
, delegate
will already be an assign
ed property declared as 如果
locationSearchBar
是UISearchBar
的实例,则delegate
将已经是一个声明为的assign
属性
@property(nonatomic, assign) id<UISearchBarDelegate> delegate
And if so, your code snippet is fine. 如果是这样,您的代码段就可以了。
Otherwise, make sure delegate
is declared as 否则,请确保
delegate
声明为
@property (weak) id <YourProtocol> delegate
within the class's header. 在类的标题中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.