我正在使用 ARC 为 iOS 4 编写应用程序。我通过标准委托(delegate)模式呈现和解除模态视图 Controller 。 iOS 4 中的 ARC 不支持弱引用,因此,我将 subview Controller 的委托(delegate)属性标记为 assign
。我应该在 subview Controller 的dealloc方法中将该委托(delegate)设置为nil吗?
最佳答案
应该没关系。您的 child 仅使用委托(delegate)向父 View Controller 发送消息。您的 subview Controller 在释放后不会对父 View 进行任何调用,因此您不需要将委托(delegate)清零。通过使用 allocate 或weak,您还没有取得父级的所有权角色,因此无需将内存管理委托(delegate)置零。
关于ios - 使用 ARC 将模态视图 Controller 的委托(delegate)设置为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10993290/