自动引用计数(ARC)表示禁止调用[super dealloc] ...有什么替代方案? [英] Automatic Reference Counting (ARC) says that invoking [super dealloc] is forbidden...what is the alternative?

查看:295
本文介绍了自动引用计数(ARC)表示禁止调用[super dealloc] ...有什么替代方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始使用iOS5,我已经为我的项目启用了ARC。我有一个类在deallocation我保存该对象的状态。

I'm starting to use iOS5 and I've enabled ARC for my project. I have a class where on deallocation I save the state of that object.

-(void)dealloc {
    [self save];
    [super dealloc];
}

但是,在ARC下, [super dealloc] 是不允许的?我认为如果在这种情况下你没有在超类上调用dealloc方法它被认为是一个错误?

However, under ARC, [super dealloc] is not allowed? I thought that it was considered a bug if you don't invoke the dealloc method on the super class in this situation?

那么现在解除对象的适当方法是什么?

So what is the appropriate way to dealloc objects now?

推荐答案

iOS 5中的ARC属于NDA。也就是说,根据clang官方网站上的公开信息判断,你只是不写 [super dealloc] 这是由编译器。请参阅规范的 7.1.2

ARC in iOS 5 is under NDA. That said, judging from publicly available information at the official site of clang, you just don't write [super dealloc]. That's generated automatically by the compiler. See the clause 7.1.2 of the specification.

这篇关于自动引用计数(ARC)表示禁止调用[super dealloc] ...有什么替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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