Re: Memory management question (passing objects to method)
Re: Memory management question (passing objects to method)
- Subject: Re: Memory management question (passing objects to method)
- From: Evan Schoenberg <email@hidden>
- Date: Tue, 1 Mar 2005 02:45:16 -0600
On Mar 1, 2005, at 2:24 AM, Jiva DeVoe wrote:
You should instead do:
-(void)doSomething:(NSString *)aVar;
{
localInstanceOfVar = [aVar retain];
}
And moreover, you want to do either:
-(void)doSomething:(NSString *)aVar;
{
[localInstanceOfVar autorelease];
localInstanceOfVar = [aVar retain];
}
or
-(void)doSomething:(NSString *)aVar;
{
if(localInstanceOfVar != aVar){
[localInstanceOfVar release];
localInstanceOfVar = [aVar retain];
}
}
because you want to release the old value before retaining the new one.
-Evan
_______________________________________________
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