在dealloc中使用iVars上的self? [英] Using self on iVars in dealloc?

查看:176
本文介绍了在dealloc中使用iVars上的self?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常我写我的dealloc看起来像这样:

Usually I write my dealloc to look like this:

- (void)dealloc {
    [coffeeList release];
    [super dealloc];
}

但是今天我输入(见下文)通过CLANG静态分析器运行代码的错误。正如我所说,我通常不会在dealloc中添加self到iVars,但是只是有点好奇,当我发现这是发生了什么。

But today I typed (see below) and was a little puzzled why I got an error running the code through the CLANG static analyser. As I say I don't usually add self to iVars in dealloc, but was just a little curious when I spotted this as to what was going on.

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

gary。

推荐答案

因为这真的很糟糕的形式,反对你应该如何做的事情。 CSA不只是检查语义错误,它还检查你做的事情你应该的方式。你应该的方式,是文档中的操作方式。

Because that's really bad form, and goes against how you should be doing things. CSA doesn't just check for semantic errors, it also checks that you're doing things the way you should be. Where the way you should be, is the way things are done in the documentation.

这篇关于在dealloc中使用iVars上的self?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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