Objective-c - Why are parent class initializers called different in swift initialization and object-c initialization?
習慣沉默
習慣沉默 2017-05-02 09:26:32
0
0
779

In swift, we must confirm that the subclass has completed the initialization work before calling the parent class initializer, as follows:

class SubObject: CustomObject {
    var dogName: String
    override init() {
        dogName = "大黄"
        super.init()
    }
}

In Object-c, we must first confirm that the parent class has completed initialization before initializing the subclass:

- (instancetype)init{
    self = [super init];
    if (self) {
        
    }
    return self;
}

Is this the reason?

習慣沉默
習慣沉默

reply all(0)
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template