Archive for July, 2007

Retain/Autorelease in Cocoa Getters

Someone asked me: “Why do some getters do:

- (id)object;
{
    return _object;
}

and others do:

- (id)object;
{
    return [[_object retain] autorelease];
}

…?”

The difference comes up in a special case which can cause a crash.
Read more »