iphone - 将 delegate 设置为 nil 到 "avoid message sent to deallocated instance"

标签 iphone objective-c

如果你有一个实现委托(delegate)的 View Controller ,那么在释放委托(delegate)时你应该将委托(delegate)设置为 nil 吗?我一直收到此消息。

我不确定“将委托(delegate)设置为nil”,这是什么意思?有人可以给我一个简单的例子来澄清这一点吗?

最佳答案

在释放 SomeObject 的旧委托(delegate)之前,您很可能只需要执行“SomeObject.delegate = nil”即可。您能否提供发生此警告的任何代码片段?

关于iphone - 将 delegate 设置为 nil 到 "avoid message sent to deallocated instance",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6171064/

相关文章:

iOS - ScopeBar 与 TabBarController 中的 UISearchController 中的 SearchBar 重叠

c# - UITableViewDelegate 中的问题 - RowSelected 给出了错误的 NSIndexPath

iphone - 旋转 UI 图像?

iphone - 为什么 Apple 开发站点上的这段代码示例为同一个类声明了三个接口(interface)?

iphone - PayPal iOS MECL getInstance方法崩溃

ios - 如何在 boundingRectWithSize 中指定 NSLineBreakMode?

Storyboard 中的 iOS Swift 启动画面

ios - 按时间错误使用 NSSortDescriptor 排序(带有核心数据)

iphone - 内存泄漏 - Objective-C

ios - 如何将静态 UIButton 覆盖在 UITableView 上