• 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: When init returns nil does it cause a leak
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: When init returns nil does it cause a leak


  • Subject: Re: When init returns nil does it cause a leak
  • From: Michael Ash <email@hidden>
  • Date: Tue, 19 May 2009 14:51:53 -0400

On Tue, May 19, 2009 at 2:24 PM, Gwynne Raskind <email@hidden> wrote:
> On May 19, 2009, at 2:15 PM, Jesper Storm Bache wrote:
>>
>> In the obj-c world we then have to implement classes to be able to handle
>> a dealloc call before the initializer has completely executed.
>
> My 2 cents...
>
> If we aren't implementing our classes this way to begin with, then we're not
> programming our Objective-C correctly at all. As far as I'm concerned,
> "dealloc should be able to handle a partially initialized object" should be
> a language requirement. If any of Apple's classes don't handle this case
> properly, then it's a bug that should be filed.

Since your instance variables are guaranteed to be zero-filled as soon
as the object is allocated, even before initialization, writing your
dealloc method to correctly handle an uninitialized object should be
trivial. Most dealloc methods will work with zero modification, and
where changes are needed, they tend to be useful belt-and-suspenders
checks anyway.

Mike
_______________________________________________

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: 
 >When init returns nil does it cause a leak (From: Reza Farhad <email@hidden>)
 >Re: When init returns nil does it cause a leak (From: Jesper Storm Bache <email@hidden>)
 >Re: When init returns nil does it cause a leak (From: Quincey Morris <email@hidden>)
 >Re: When init returns nil does it cause a leak (From: Jesper Storm Bache <email@hidden>)
 >Re: When init returns nil does it cause a leak (From: Gwynne Raskind <email@hidden>)

  • Prev by Date: TableView & TextFieldCell question...
  • Next by Date: Re: Cancelling an animation in a UITableViewCell was Re: UITableViewCell instances
  • Previous by thread: Re: When init returns nil does it cause a leak
  • Next by thread: Re: When init returns nil does it cause a leak
  • Index(es):
    • Date
    • Thread