FROM : Quincey Morris
DATE : Wed Mar 26 01:09:34 2008
On Mar 25, 2008, at 16:26, Andy Lee wrote:
> A similar question was asked recently. To paraphrase (and slightly
> correct) my reply:
>
> I do essentially this:
>
> - (id)init
> {
> NSLog(@"%@ -- '%@' is not the designated initializer",
> [self class],
> NSStringFromSelector(_cmd));
> [self release];
> return nil;
> }
Unless there is some special runtime magic going on, this seems not
absolutely safe. Your '[self release]' is going to eventually lead to
a call of '[super dealloc]' and theoretically you can't safely call
the superclass's dealloc if you haven't called a designated superclass
initializer, because you don't know what the superclass's dealloc
expects its initializer to have already done.
In practice, though, I can't imagine anything really bad happening --
all the dealloc has available to run amok with is a bunch of zeroes.
DATE : Wed Mar 26 01:09:34 2008
On Mar 25, 2008, at 16:26, Andy Lee wrote:
> A similar question was asked recently. To paraphrase (and slightly
> correct) my reply:
>
> I do essentially this:
>
> - (id)init
> {
> NSLog(@"%@ -- '%@' is not the designated initializer",
> [self class],
> NSStringFromSelector(_cmd));
> [self release];
> return nil;
> }
Unless there is some special runtime magic going on, this seems not
absolutely safe. Your '[self release]' is going to eventually lead to
a call of '[super dealloc]' and theoretically you can't safely call
the superclass's dealloc if you haven't called a designated superclass
initializer, because you don't know what the superclass's dealloc
expects its initializer to have already done.
In practice, though, I can't imagine anything really bad happening --
all the dealloc has available to run amok with is a bunch of zeroes.
| Related mails | Author | Date |
|---|---|---|
| Andy Klepack | Mar 25, 23:01 | |
| Quincey Morris | Mar 26, 00:06 | |
| Andy Lee | Mar 26, 00:26 | |
| Kyle Sluder | Mar 26, 00:38 | |
| Quincey Morris | Mar 26, 01:09 | |
| Chris Suter | Mar 26, 01:42 | |
| Andy Lee | Mar 26, 04:47 |






Cocoa mail archive

