Re: Autorelease/Retain/Release
Re: Autorelease/Retain/Release
- Subject: Re: Autorelease/Retain/Release
- From: Nick Zitzmann <email@hidden>
- Date: Tue, 24 Jul 2007 20:01:23 -0600
On Jul 24, 2007, at 7:49 PM, Tim Davis wrote:
Does this mean that if I don't send the object a [retain] call
during the [[blah alloc] init] statement that I don't need to send
it a [release] later on? Yes I have read the docs, just unsure
about it.
Incorrect. Objects created with alloc/init are not autoreleased, so
they must be manually released, unless you're using Leopard and have
garbage collection turned on.
I created an autorelease pool farther up the awakeFromNib
function. Please look at indexRoot, indexFile, and xmlData. If I
understand this correctly I need to use autorelease on indexRoot
and indexFile because I'm alloc'ing and init'ing? And xmlData is
automagicly destroyed when awakeFromNib exits?
Correct, although you don't have to create your own pools unless:
1. You just detached a new thread.
2. You've created a loop that creates lots of objects and want to
collect garbage every now and then.
3. You're in the main thread and never call NSApplicationMain().
Nick Zitzmann
<http://www.chronosnet.com/>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden