FROM : Scott Stevenson
DATE : Sat Apr 28 22:32:10 2007
On Apr 28, 2007, at 11:49 AM, Paul Borokhov wrote:
> The reason I was thinking that the [self release] is legal is
> because the object is initially created with an instance method
> that calls [super init] (not a convenience class method), and so it
> seems to make sense that someone needs to release it too.
Ah, I see. Actually, In a situation like this:
- (id)init
{
if (self = [super init])
{
//...
}
return self;
}
You're not responsible for releasing yourself later, the original
caller is.
If helps to arrange things in your head, keep in mind [self release]
is not the counterpart to [super init].
That is, "self" refers to an instance, "super" refers to a class.
- Scott
DATE : Sat Apr 28 22:32:10 2007
On Apr 28, 2007, at 11:49 AM, Paul Borokhov wrote:
> The reason I was thinking that the [self release] is legal is
> because the object is initially created with an instance method
> that calls [super init] (not a convenience class method), and so it
> seems to make sense that someone needs to release it too.
Ah, I see. Actually, In a situation like this:
- (id)init
{
if (self = [super init])
{
//...
}
return self;
}
You're not responsible for releasing yourself later, the original
caller is.
If helps to arrange things in your head, keep in mind [self release]
is not the counterpart to [super init].
That is, "self" refers to an instance, "super" refers to a class.
- Scott
| Related mails | Author | Date |
|---|---|---|
| Paul Borokhov | Apr 28, 19:52 | |
| Scott Stevenson | Apr 28, 20:19 | |
| Paul Borokhov | Apr 28, 20:49 | |
| Buddy Kurz | Apr 28, 21:34 | |
| Scott Stevenson | Apr 28, 22:32 | |
| Paul Borokhov | Apr 28, 23:01 | |
| Shawn Erickson | Apr 29, 00:11 | |
| Matt Neuburg | Apr 30, 01:52 |






Cocoa mail archive

