Kaiserludi
Kaiserludi

Reputation: 2472

implementing convenience constructors for automatic reference counting

Without automatic reference counting you often write code like this, when adding a new class:

assuming the classname is "Foo"

+ (id) foo
{
    return [[[self alloc] init] autorelease];
}

- (id) init
{
    self = [super init];
    // do some initialization here
    return self;
}

Well, how are you supposed, to write this for arc? Just like the code below?

+ (id) foo
{
    return [[self alloc] init];
}

- (id) init
{
    self = [super init];
    // do some initialization here
    return self;
}

Upvotes: 3

Views: 1314

Answers (1)

Rob Napier
Rob Napier

Reputation: 299345

Yes. Are you expecting something different?

Upvotes: 1

Related Questions