首页 > 开发 > iOS > 正文

已经开启了ARC dealloc 还可以用?

2017-09-08 14:04:01  来源:网友分享

我的工程已经开启ARC了,但是我看-(void)dealloc还是可以实现的,那这个方法还是会被调用吗?还是就是个摆设?
什么时候会调用它?ARC都开起来了,这个留着还有什么用

解决方案

官方文档说得很清楚http://developer.apple.com/library/ma...

You may implement a dealloc method if you need to manage resources other than releasing instance variables. You do not have to (indeed you cannot) release instance variables, but you may need to invoke [systemClassInstance setDelegate:nil] on system classes and other code that isn’t compiled using ARC.

用来在dealloc的时候手动解除delegate关系。