discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to set value in NSArray


From: Richard Frith-Macdonald
Subject: Re: How to set value in NSArray
Date: Tue, 13 Jul 2004 20:18:30 +0100


On 13 Jul 2004, at 19:49, James McLoughlin wrote:

Hi

A quick (naive) question on your destructor...

@implementation MyClass
- (void) dealloc
{
  DESTROY(monthlyRain);
  [super dealloc];
}

Why is the DESTROY function used as opposed to

It's a macro ... and I just used it from habit

[monthlyRain dealloc];

Using DESTROY is equivalent to sending a -release message and then
setting the variable to be nil.  It is *not* equivalent to -dealloc

While dealloc would be fine in this simple example, it would generally
be a bad idea in cases where the class might contain an accessor
method which could have given some other code access to monthlyRain,
so the other code might have retained it.

?

Is this specific to gnustep, or is it also a convention in openStep / Cocoa?

The DESTROY() macro is GNUstep specific, though GNUstep provides a header file
which can be used to make some convenience macros available in Cocoa.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]