When init returns nil does it cause a leak

2009-05-19 Thread Reza Farhad
Hi all we have an object that gets initialized like most other objects -(id)init { self = [ super init ]; if ( self ){ ...do something; } return self; } if [ super init ] returns nil does this cause a leak, as the memory has already been

Re: When init returns nil does it cause a leak

2009-05-19 Thread Jesper Storm Bache
Apple's take on this is that when an initializer fails, then it should call release on itself and return nil. See: http://developer.apple.com/documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocAllocInit.html#/ /apple_ref/doc/uid/TP30001163-CH22-SW13 This means that if super returns nil,

Re: When init returns nil does it cause a leak

2009-05-19 Thread Jean-Daniel Dupas
Le 19 mai 09 à 18:24, Reza Farhad a écrit : Hi all we have an object that gets initialized like most other objects -(id)init { self = [ super init ]; if ( self ){ ...do something; } return self; } if [ super init ] returns nil does this cause

Re: When init returns nil does it cause a leak

2009-05-19 Thread Quincey Morris
On May 19, 2009, at 09:32, Jesper Storm Bache wrote: I personally disagree with the Apple recommendation, and I vote for calling [super dealloc] when initialization fails - because this will invoke dealloc only in the base classes where init succeeded. First of all, in general, it can't

Re: When init returns nil does it cause a leak

2009-05-19 Thread Jesper Storm Bache
On May 19, 2009, at 10:58 AM, Quincey Morris wrote: On May 19, 2009, at 09:32, Jesper Storm Bache wrote: I personally disagree with the Apple recommendation, and I vote for calling [super dealloc] when initialization fails - because this will invoke dealloc only in the base classes where init

Re: When init returns nil does it cause a leak

2009-05-19 Thread Gwynne Raskind
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

Re: When init returns nil does it cause a leak

2009-05-19 Thread Michael Ash
On Tue, May 19, 2009 at 2:24 PM, Gwynne Raskind gwy...@darkrainfall.org 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

Re: When init returns nil does it cause a leak

2009-05-19 Thread Nathan Vander Wilt
On May 19, 2009, at 9:37 AM, Jean-Daniel Dupas wrote: Le 19 mai 09 à 18:24, Reza Farhad a écrit : Hi all we have an object that gets initialized like most other objects -(id)init { self = [ super init ]; if ( self ){ ...do something; } return

Re: When init returns nil does it cause a leak

2009-05-19 Thread Jesper Storm Bache
I did talk to an Apple engineer about this and when I argued for [super dealloc] I was told that it would be fine. I then logged a radar against the seemingly incorrect documentation, I got a reply stating that [self release] is the recommended approach by the AppKit team. My radar was