• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: release and reference counting query
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >release and reference counting query (From: Calum Robertson <email@hidden>)
 >Re: release and reference counting query (From: Roland King <email@hidden>)
 >Re: release and reference counting query (From: Marc Stibane <email@hidden>)
 >Re: release and reference counting query (From: Peter N Lewis <email@hidden>)

  • Prev by Date: Re: Window title bar accessory view
  • Next by Date: NSArrayController - Remove all objects?
  • Previous by thread: Re: release and reference counting query
  • Next by thread: Re: release and reference counting query
  • Index(es):
    • Date
    • Thread