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: Tim Lucas <email@hidden>
- Date: Thu, 3 Mar 2005 13:58:28 +1100
On 02/03/2005, at 4:46 PM, mmalcolm crawford wrote:
That said, this pattern is unusual, and you are encouraged to use
standard accessor methods pervasively. Better than the above would be
to simply invoke:
[object setBlah:nil];
And also just to add to the above, this is the pattern you should use
in your dealloc methods (you all write delloc methods, right?!).
For example, if you have something like the following:
- (id)init
{
if(self = [super init])
{
[self setName:@""];
}
return self;
}
- (void)setName:(NSString*)aString
{
if(aString != name)
{
[name release];
name = [aString retain]; // (or copy if you want)
}
}
then your dealloc should look like:
- (void)dealloc
{
[self setName:nil];
[super dealloc];
}
- tim lucas
_______________________________________________
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