Re: release and reference counting query
Re: release and reference counting query
- Subject: Re: release and reference counting query
- From: Andy Lee <email@hidden>
- Date: Tue, 18 Nov 2008 22:17:35 -0500
On Nov 18, 2008, at 8:24 PM, Peter N Lewis wrote:
I would actually write:
self.viewController = [[[UIViewController alloc]
initWithNibName:@"MoveMeView" bundle:[NSBundle mainBundle]]
autorelease];
I like this best too. I like combining the autorelease with the alloc/
init because you don't have to worry about forgetting to do the
release later. And this addresses the brevity issue that Marc asked
about.
The ivar setting method is much more risky - changes far away from
this code could introduce bugs.
Exactly. Although conceptually we are initializing the ivar, this is
not happening in an init method and it's better not to assume the ivar
is null.
--Andy
_______________________________________________
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