RE: How To Increment CALayer Retain Count?
RE: How To Increment CALayer Retain Count?
- Subject: RE: How To Increment CALayer Retain Count?
- From: Lee Ann Rucker <email@hidden>
- Date: Sun, 10 Apr 2011 01:44:09 -0700
- Acceptlanguage: en-US
- Thread-topic: How To Increment CALayer Retain Count?
________________________________________
From: Jeffrey Walton [email@hidden]
Sent: Sunday, April 10, 2011 1:03 AM
To: Lee Ann Rucker
Cc: email@hidden
Subject: Re: How To Increment CALayer Retain Count?
On Sun, Apr 10, 2011 at 3:54 AM, Lee Ann Rucker <email@hidden> 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 (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