________________________________________
From: Jeffrey Walton [noloa...@gmail.com]
Sent: Sunday, April 10, 2011 1:03 AM
To: Lee Ann Rucker
Cc: cocoa-dev@lists.apple.com
Subject: Re: How To Increment CALayer Retain Count?

On Sun, Apr 10, 2011 at 3:54 AM, Lee Ann Rucker <lruc...@vmware.com> wrote:
> What does your @property line look like for your variables? If it's retain, 
> then "(x) = nil;" in your macro is releasing it again. That's the magic of 
> dot operator assign in ObjC.
@property (retain, nonatomic) IBOutlet UINavigationBar* navigationBar;

That probably explains it. I imagine I read it in one of my books, but
did not appreciate what was being said at the time.

> I imagine those macros exist because using "self.foo = nil" in dealloc can 
> have unwanted side effects, so they're a convenient shortcut for not having 
> to write the same two lines over and over.

I know its not very popular, but I've disciplined myself to set all
variables (including stack) to their low or unused state when finished
with them. It helps locate reuse problems in Debug builds (and I
really don't care a bit about the 3 cycles). The optimizer can remove
it later if it desires.

---

Sure, setting the variable to nil in dealloc is good practice, just either do 
it with
[foo release];
foo = nil;

or 
self.foo = nil;
if you're sure there's no side effects. But not both 
:)_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to