Re: autorelease use...
Re: autorelease use...
- Subject: Re: autorelease use...
- From: mmalcolm crawford <email@hidden>
- Date: Mon, 18 Jul 2005 10:13:59 -0700
On Jul 18, 2005, at 7:20 AM, Tristan O'Tierney wrote:
for example say you do:
- ( void ) myFunction {
NSString *str = [NSString stringWithString: @"my string"];
}
once you reach the end of myFunction, you are NOT guaranteed that the
contents of str will still exist, as it has been autoreleased and
upon the
next iteration of the event loop this object will be released /
dealloced.
however, say you want to pay attention to this variable and keep it
for
later use, you would then do a retain:
- ( void ) myFunction {
NSString *str = [NSString stringWithString: @"my string"];
[str retain];
}
NO!
This is not right.
Please, there are any number of resources that properly describe
Cocoa's memory management model. There is typically very little
point in trying to write your own reference in response to a question
-- especially if you then get it wrong.
mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden