Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
self.locationSearchBar.delegate = self;
我相信我在这里发生了一个保留周期,而且我一生都无法记住如何给代表一个对自我的弱引用。有人可以告诉我如何完成这项工作吗?
IflocationSearchBar是 , 的一个实例UISearchBar,delegate将已经是一个assigned 属性声明为
locationSearchBar
UISearchBar
delegate
assign
@property(nonatomic, assign) id<UISearchBarDelegate> delegate
如果是这样,您的代码片段就很好。
否则,请确保delegate声明为
@property (weak) id <YourProtocol> delegate
在类的标题中。