How to call designated superclass initializers in Swift

objective-c, swift, uiview

Solution

Like this

init(frame: CGRect) {
    super.init(frame: frame)
    // Initialization code
}

Problem

In Objective-C there is this standard pattern in initializers to call the designated initializer of the superclass. For example: ``` - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { // Initialization code } return self; } ``` What is the standard way to do the same initialization in a Swift class?

Original source