by Gregory Weston <uce@[EMAIL PROTECTED]
>
May 6, 2008 at 07:48 AM
In article
<59172f59-0309-4061-9d9d-79a262a0c0a4@[EMAIL PROTECTED]
>,
Linan <tali.wang@[EMAIL PROTECTED]
> wrote:
> Hi,
> I just spent few hours and finally understand the two memory
> management methods. I think the the pair just do not make sense (or
> conceptually illogic). I feel it would be better if NSObject has two
> other methods:
> -(void) retain:(id)obj;
> -(void) release:(id)obj;
> In the dog and leash analogy suggested in the Aaron Hillegass's book,
> it's the owners of the dog retain or release the dog, but in object-c
> the dog has to release/retain itself.
> The real advantage of the idea is when using NSAutoreleasePool. It
> would be conceptually simpler and more consistent than autorelease
> method. We even don't need this method any more. Just alloc/init an
> autoreleasepool and it again has the retain:(id)obj and release:
> (id)obj methods.
>
> How do you think? Please correct me if I failed to capture something
> behind the design. Thanks
>
> Linan Wang
The most glaring flaw is that an object is not always retained by
another object.
I'd also argue that IMO
[foo retain];
is more pleasant to deal with than
[[NSAutoreleasePool currentPool] retain:foo];
would be.
--
"Harry?" Ron's voice was a mere whisper. "Do you smell something ...
burning?"
- Harry Potter and the Odor of the Phoenix