Re: -retain and -release Questions
Re: -retain and -release Questions
- Subject: Re: -retain and -release Questions
- From: Clark Cox <email@hidden>
- Date: Sun, 7 Mar 2004 10:08:09 -0500
On Mar 07, 2004, at 02:20, Jerry Krinock wrote:
>
>
Generally, if I create (-alloc and -init) an object for temporary use
>
only
>
within one method, I believe I need to -release this object before the
>
method returns.
Correct, you are responsible for releasing any object that you created
via +alloc, +allocWithZone:, +copy, +copyWithZone:, or on which you
called -retain.
>
This is in contrast to C++, where objects are automatically
>
deleted when they go out of scope. Is this correct?
Yes, for automatic C++ objects, but as all Objective-C objects are
allocated on the heap, the more analogous situation is that of objects
created via the new operator, you are responsible for using the delete
operator to destroy the object.
>
Am I correct in saying that the only bad effect of omitting a -release
>
or
>
-autorelease message is that it causes a memory leak?
Unless the object to be released does something important in it's
-dealloc method (close/flush a file, etc)
--
Clark S. Cox III
email@hidden
http://homepage.mac.com/clarkcox3/
http://homepage.mac.com/clarkcox3/blog/B1196589870/index.html
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.