Skip navigation.
 
mlRe: Memory management/freeing with delegate methods
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

Related mailsAuthorDate
mlMemory management/freeing with delegate methods Paul Borokhov Apr 28, 19:52
mlRe: Memory management/freeing with delegate methods Scott Stevenson Apr 28, 20:19
mlRe: Memory management/freeing with delegate methods Paul Borokhov Apr 28, 20:49
mlRe: Memory management/freeing with delegate methods Buddy Kurz Apr 28, 21:34
mlRe: Memory management/freeing with delegate methods Scott Stevenson Apr 28, 22:32
mlRe: Memory management/freeing with delegate methods Paul Borokhov Apr 28, 23:01
mlRe: Memory management/freeing with delegate methods Shawn Erickson Apr 29, 00:11
mlRe: Memory management/freeing with delegate methods Matt Neuburg Apr 30, 01:52