ios - 已经开启了ARC dealloc 还可以用?
怪我咯
怪我咯 2017-04-17 11:05:49
[iOS讨论组]

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

怪我咯
怪我咯

走同样的路,发现不同的人生

全部回复(3)
迷茫

官方文档说得很清楚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关系。

PHP中文网

dealloc当然会被调用(通常是以被编译器自动插入代码的方式),也可以实现(尤其是如果有某些非Cocoa对象资源需要管理的时候)。

参考 CLANG 相关文档

黄舟

仍会在对象彻底释放前调用dealloc方法。

ARC与非ARC的区别:ARC中dealloc中不得显式调用[super dealloc]、不得显式[obj release]。

而无需声明(编译自动生成)dealloc是SDK4就有的特性,和ARC无关。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号