Objective-Cでは、カスタム初期化ロジックを追加するために、サブクラスの継承されたすべてのコンストラクターをオーバーライドする必要がありますか?
たとえば、UIView
カスタム初期化ロジックを持つサブクラスの場合、次は正しいでしょうか?
@implementation CustomUIView
- (id)init {
self = [super init];
if (self) {
[self initHelper];
}
return self;
}
- (id)initWithFrame:(CGRect)theFrame {
self = [super initWithFrame:theFrame];
if (self) {
[self initHelper];
}
return self;
}
- (id)initWithCoder:(NSCoder *)decoder {
self = [super initWithCoder:decoder];
if (self) {
[self initHelper];
}
return self;
}
- (void) initHelper {
// Custom initialization
}
@end