Secondary initializer delegates to super instead of self

ID

objectivec.correctness.super_self

Severity

low

Remediation Complexity

medium

Remediation Risk

medium

Remediation Effort

medium

Resource

Api Misuse

Language

Objective-C

Description

This initializer delegates to a DIFFERENT initializer on super instead of on self. Only the designated initializer may chain up to the superclass, and it must do so under the same selector; a secondary initializer has to delegate sideways, through self, so that the class’s own designated initializer runs and a subclass’s override of it is honoured. Going through super skips both and leaves the object half-initialised. Send the message to self.

Rationale

This initializer delegates to a DIFFERENT initializer on super instead of on self. Only the designated initializer may chain up to the superclass, and it must do so under the same selector; a secondary initializer has to delegate sideways, through self, so that the class’s own designated initializer runs and a subclass’s override of it is honoured. Going through super skips both and leaves the object half-initialised. Send the message to self.

The following code illustrates the pattern detected by this rule:

@implementation Widget
// FLAGGED: Secondary initializer delegates to super instead of self
- (instancetype)init {
    self = [super initWithFrame:CGRectZero];
    if (self) {
        _style = 0;
    }
    return self;
}
@end

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved