Helge Hess wrote:
This doesn't work on gstep-base, because the NSNotification created
retains and afterwards releases the "object:self". This somehow
results in a duplicate call to -dealloc (because the RC apparently
reaches "0" twice).
Is anyone aware of differences with regards to RC in -dealloc or has
any other ideas ?
some more info, NSObject -release looks like this in libFoundation:
---snip---
if (NSExtraRefCount(self) == 1)
[self dealloc];
else
NSDecrementExtraRefCountWasZero(self);
---snap---
and like that in gstep-base:
---snip---
if (NSDecrementExtraRefCountWasZero(self))
{
[self dealloc];
}
---snap---
(some code removed).
Actually I think that libFoundation is correct (and apparently it's
implemented in the same way in MacOSX Foundation, I'll check that in
the evening at home).
Gstep-base is implemented like it's written down in the documentation
"If anObject didn't have an extra reference count, it returns YES,
indicating that the object should be deallocated (with dealloc)". But
this breaks if the count isn't checked (resulting unnecessarily in
multiple -deallocs).
Opinions ?