Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Objective-c > Re: Retain and ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 974 of 1042
Post > Topic >>

Re: Retain and Release

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
 




 2 Posts in Topic:
Retain and Release
Linan <tali.wang@[EMAI  2008-05-05 15:34:08 
Re: Retain and Release
Gregory Weston <uce@[E  2008-05-06 07:48:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Oct 14 9:45:22 CDT 2008.