目标C-[super dealloc]旧吗? [英] Objective C - [super dealloc] old?

查看:112
本文介绍了目标C-[super dealloc]旧吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对目标c有疑问.我买了一本关于目标c的书.我是目标c的新手,这本书包括许多有关内存管理的教程.我的Mac版本为10.7.5.因此,在有关dealloc的教程中,xcode告诉我"ARC禁止显式发送'dealloc'消息".因此,我在许多论坛中搜索了此错误.在这些论坛中,许多人说[super dealloc]是从NSObject继承的,而较新的系统版本会自动进行内存管理.这本书将于2011年出版.

我希望每个人都能理解我.

谢谢.

解决方案

iOS上有一个名为ARC的新系统,该系统会自动将释放/保留/解除分配等消息发送到您的对象.您可能会在此处了解更多信息

回答问题时要注意的重要事项是ARC是可选的.您可以使用它,但不必这样做. (在创建新的XCode项目时,您可以勾选启用自动引用计数"按钮,也可以不勾选.)

因此,要回答您的问题:如果在项目中使用ARC,是的,不再需要dealloc.如果您不使用ARC,则仍然需要管理自己的内存.这取决于您如何设置项目.

i have a question about objective c. I bought a book about objective c. I am new in objective c and the book include many tutorials about memory management. I have the mac version 10.7.5. So in the tutorial about dealloc, xcode say me "ARC forbids explicit message send of 'dealloc'". So i search this error in many forums. In these forums many people say that [super dealloc] inherits from NSObject is old and the newer version of system make the memory management automatically. The book comes out 2011.

I hope everyone understand me.

Thank you in advance.

解决方案

There is a new(ish) system for iOS called ARC which automatically sends release/retain/dealloc etc. messages to your objects. You may read more about it here.

The important thing to note when answering your question is that ARC is optional. You may use it, but you do not have to. (When creating a new XCode project, you either tick the "enable automatic reference counting" button, or you don't.)

So, to answer your question: if you are using ARC in your project, yes, dealloc is no longer necessary. If you're not using ARC, you will still need to manage your own memory. It depends on how you're setting up your project.

这篇关于目标C-[super dealloc]旧吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆