I am working on an inherited codebase and trying to resolve the following warnings:
Designated initializer should only invoke a designated initializer on 'super'
Designated initializer missing a 'super' call to a designated initializer of the super class
The code is:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [self initWithFrame:[CDCUtility getScreenBounds]]; //switching to super breaks
if (self) {
}
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setArray:[NSMutableArray new]];
[self setButtonArray:[NSMutableArray new]];
_graphicEQ = [[CDCEffectsGraphicEQ alloc] initWithFrame:CGRectMake((1024 / 2) - (811 / 2), 60, 860, 255)];
[self addSubview:_graphicEQ];
[_graphicEQ setDelegate:self];
[self addBypassButtonToView];
[self addFlatButtonToView];
[self addScrollView];
}
return self;
}
So from what I can make out the developer overrode the superclass initWithCoder:
(This is a UIView
) to allow the custom UI to be loaded, and passed in this initWithFrame:
parameter using custom arguments to create the view.
I have seen some say change the [self initWithFrame:]
' in initWithCoder:
to [super initWithFrame:]
which does resolve the warnings, however it also bypasses calling the features necessary here to load the view correctly.
It works fine as is; I just wanted to cut down all possible warnings, so I wondered if changes can be made to resolve this?