Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ?
Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ?
- Subject: Re: In dealloc(): ref @property, Can I use "<property object> = nil; " vs "[<property object> release]; " ?
- From: Jim Puls <email@hidden>
- Date: Wed, 8 Oct 2008 08:59:44 -0700
On Oct 8, 2008, at 8:49 AM, Lee, Frederick wrote:
I've seen examples of using [myVar release]. But doesn't setting
myVar
= nil does the same thing?
Which is the preferred way?
This is a point of more contention than you may realize. The former
is, of course, equivalent to
[self setMyVar:nil];
which, as it calls a method on self during [self dealloc], is
something frowned upon by many. It also triggers the KVO process,
though if you're in dealloc, any KVO concerns should have finished
long ago. On the other hand, it's a "purer" OO call style and allows
you to stick with the property syntax as much as possible and lets you
worry a bit less about memory management, which is nice.
YMMV, but you're probably safer doing [myVar release];. If you ever
end up implementing your own -setMyVar: and it has side effects, there
be demons ahead.
-> jp
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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