English 中文(简体)
如果我使用自己的话。 释放时
原标题:Should I use self. when releasing

我在界定我的变数时,有一整座标的栏目。

www.un.org/Depts/DGACM/index_spanish.htm 方法,应当将其释放到[myGreatVariable release];[自.myGreatVariable release];。 他们目前以原来的方式工作。 这究竟是什么问题? 从现在起就开始,或者如果我回头来,在我的所有班子里改变所有这些班子,那是一件好事,因为事情实际上还没有释放。

最佳回答

如果你回头处理,就没有问题了,尽管前者是一个比它更有效率的渠道。 但是,您有第三种选择,即:<条码>本身.myFairly GoodVariable = nil;,该方法依靠固定方法进行释放(但两种或三种斜线的轨道效率较低)。

I suspect you ll find different arguments for what you should do. Some folks argue you should use the instance variable (sans self.) for all read accesses. Others will argue that you should use the property access (ie, with self.) pretty much everywhere. I tend to fall into the latter camp, but I could accept arguments from the other side.

但重要的是保持合理一致。 如果你与其他人合作,如果你能够有一个团队“标准”。

(我想做的一件事是将dealloc方法放在桌面上,然后在通常结束的底层。) 这样,你就更有可能记住,如果你增加/改变财产及相关的<条码>@synthesize的话,将更新<条码>。

问题回答

Don t use [自.myGreatVariable release]. 正如丹尼尔指出的,它将在这方面开展工作,但它是最“天化”的版本,并且将在<条码>-dealloc以外的任何地方做-wrong的物品,有可能在财产中留下一个停车场。

你们应选择其中一项,并实现标准化:

  1. [myGreatVariable release];
  2. self.myGreatVariable = nil;

(选择主要是个人选择。) 我只使用<代码>dealloc中的第一种形式,因为固定装置有时是非自然的,并且具有副作用,而<代码>dealloc<>/code”的目标是高效、明确地利用所有资源,避免因意外国家变化而行走。

在交易中使用“自费=无”的问题是,如果你推翻了“可变”的话,它可以引发更多的行动。 例如,有些班级将发出代表的信号,只要有变化的价值观,但你可能不想这样做。 使用“[可变释放]”就比较安全。

希望阿农发中心很快将结束所有这一切。





相关问题
Windows Mobile 6 Emulator change storage?

How do i change the size of the Windows Mobile 6 Emulator. Its fixed at 32mb. I read this post: Increasing Windows Mobile 5 Emulator Storage But it only helps for the 5.0 version. Isnt there any way ...

CUDA Memory Allocation accessible for both host and device

I m trying to figure out a way to allocate a block of memory that is accessible by both the host (CPU) and device (GPU). Other than using cudaHostAlloc() function to allocate page-locked memory that ...

RAM memory reallocation - Windows and Linux

I am working on a project involving optimizing energy consumption within a system. Part of that project consists in allocating RAM memory based on locality, that is allocating memory segments for a ...

Should I send retain or autorelease before returning objects?

I thought I was doing the right thing here but I get several warnings from the Build and Analyze so now I m not so sure. My assumption is (a) that an object I get from a function (dateFromComponents: ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

doubts regarding Memory management in .net

I m learning about Memory management in C# from the book "Professional C#" The presence of the garbage collector means that you will usually not worry about objects that you no longer need; ...

Objective-C returning alloc d memory in a function == bad?

This is on the iPhone. So what if I have a function like - (SomeObject*)buildObject; Do I need to pass in a variable that I have already alloc d outside like - (void)assignObject(SomeObject** out);...

热门标签