Overriding init in subclass

前端 未结 3 1433
野趣味
野趣味 2020-12-24 01:18

In Objective-C, is it necessary to override all inherited constructors of a subclass to add custom initialization logic?

For example, would the following be correct

3条回答
  •  没有蜡笔的小新
    2020-12-24 01:51

    In case of using Interface Builder, the one is called is :

    - (id)initWithCoder:(NSCoder *)coder
    {
        self = [super initWithCoder:coder];
        if (self) {
           //do sth
        }
        return self;
    }
    

提交回复
热议问题