Re: How far with accessors?
Re: How far with accessors?
- Subject: Re: How far with accessors?
- From: cricket <email@hidden>
- Date: Wed, 26 May 2004 16:27:59 -0700
[self setTheString:nil] will release the object and nil out the
instance variable in one swell foop. That's why it's a nice way to do
it.
- cricket
On May 26, 2004, at 2:58 PM, Jeff Biggus wrote:
The preferred method is
-(void)dealloc {
[self setTheString:nil];
...
}
Perhaps I need to read the whole thread, but I've never seen it
suggested that one should simply nil out an object. In general, the
preferred way is simply to do a release:
-(void)dealloc {
[theString release];
...
[super dealloc];
}
Directly setting the object to nil should not be the first option. It
will not be necessary if there are no memory management holes in your
code. It seems like bad form to just set it to nil, though it may not
cause any problems (I'm not sure of this either way).
Some developers will write "theString = nil;" after releasing the
object, but this is only to protect against memory management mistakes
that can happen during development. It's perfectly safe, but it's a
band aid which shouldn't need to be there, afaiu.
_______________________________________________
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.